summaryrefslogtreecommitdiff
path: root/shroud
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-08-15 23:12:38 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-08-15 23:12:38 -0400
commit08ed08da752e86011a5402e5f1282916614a1cb9 (patch)
tree0105114ff0d071da5ead26737d91e993d10537b0 /shroud
parent069797dc88e3b19e8656d3f7326ef57243ea2977 (diff)
utils: Add alist-pick.
* shroud/utils.scm (alist-pick): New procedure.
Diffstat (limited to 'shroud')
-rw-r--r--shroud/utils.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/shroud/utils.scm b/shroud/utils.scm
index 20545e1..59dbbc2 100644
--- a/shroud/utils.scm
+++ b/shroud/utils.scm
@@ -24,6 +24,7 @@
vhash-replace
vhash-values
alist-compact
+ alist-pick
gpg-binary
call-with-encrypted-output-file
call-with-decrypted-input-file))
@@ -58,6 +59,16 @@ such key."
(loop tail (cons key keys)
(alist-cons key value result)))))))
+(define (alist-pick alist key)
+ "Return a list of the values in ALIST that are associated with KEY."
+ (fold-right (lambda (key+value result)
+ (match key+value
+ ((k . value)
+ (if (equal? key k)
+ (cons value result)
+ result))))
+ '() alist))
+
(define gpg-binary (make-parameter "gpg"))
(define (call-with-pipe* program+args mode proc)