summaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2021-04-25 22:34:06 +0530
committerArun Isaac2021-04-26 00:23:37 +0530
commit03ea705f5e6162d6d9dc7417e0db14d96c5715bb (patch)
tree85f2a2e47050dcfb89bb502b5ae37490364ada7d /ccwl
parentc1a8a656005d79ebcdd2e4e0a2bfbb111da0dfe3 (diff)
downloadccwl-03ea705f5e6162d6d9dc7417e0db14d96c5715bb.tar.gz
ccwl-03ea705f5e6162d6d9dc7417e0db14d96c5715bb.tar.lz
ccwl-03ea705f5e6162d6d9dc7417e0db14d96c5715bb.zip
Add plist->alist.
* ccwl/utils.scm (pairify, plist->alist): New public functions.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/utils.scm20
1 files changed, 19 insertions, 1 deletions
diff --git a/ccwl/utils.scm b/ccwl/utils.scm
index 4f041a7..c20aae1 100644
--- a/ccwl/utils.scm
+++ b/ccwl/utils.scm
@@ -27,7 +27,25 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-71)
#:use-module (ice-9 match)
- #:export (lambda**))
+ #:export (pairify
+ plist->alist
+ lambda**))
+
+(define (pairify lst)
+ "Return a list of pairs of successive elements of LST."
+ (match lst
+ (() '())
+ ((first second tail ...)
+ (cons (cons first second)
+ (pairify tail)))))
+
+(define (plist->alist plist)
+ "Convert the property list PLIST to an association list. A property
+list is a list of the form (#:key1 value1 #:key2 value2 ...)."
+ (map (match-lambda
+ ((key . value)
+ (cons (keyword->symbol key) value)))
+ (pairify plist)))
(define* (group-keyword-arguments args #:optional (unary-keywords (list)))
"Group ARGS, a list of keyword arguments of arbitrary arity. Return