From eb6e3ad5d1612a8ccb2b4ad5e1c1e62187d6f0e9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 11 Jun 2015 08:58:29 -0400 Subject: squash me. * shroud/utils.scm (alist-compact): New procedure. --- shroud/utils.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) -- cgit v1.2.3