summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)