summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <davet@gnu.org>2015-06-11 08:58:29 -0400
committerDavid Thompson <davet@gnu.org>2015-06-11 08:58:29 -0400
commiteb6e3ad5d1612a8ccb2b4ad5e1c1e62187d6f0e9 (patch)
tree9dd78286f2186b8b5971845d82c6108f4385780d
parent3f49b3a0c25fe4e1f99da1e466e87b5b34732344 (diff)
squash me.
* shroud/utils.scm (alist-compact): New procedure.
-rw-r--r--shroud/utils.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/shroud/utils.scm b/shroud/utils.scm
index e3b317d..20545e1 100644
--- a/shroud/utils.scm
+++ b/shroud/utils.scm
@@ -23,6 +23,7 @@
#:export (vhash-ref
vhash-replace
vhash-values
+ alist-compact
gpg-binary
call-with-encrypted-output-file
call-with-decrypted-input-file))
@@ -44,6 +45,19 @@ such key."
(cons value result))
'() vhash))
+(define (alist-compact alist)
+ "Remove all duplicate keys from ALIST."
+ (let loop ((alist alist)
+ (keys '())
+ (result '()))
+ (match alist
+ (() (reverse result))
+ (((key . value) . tail)
+ (if (member key keys)
+ (loop tail keys result)
+ (loop tail (cons key keys)
+ (alist-cons key value result)))))))
+
(define gpg-binary (make-parameter "gpg"))
(define (call-with-pipe* program+args mode proc)