From 08ed08da752e86011a5402e5f1282916614a1cb9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 15 Aug 2015 23:12:38 -0400 Subject: utils: Add alist-pick. * shroud/utils.scm (alist-pick): New procedure. --- shroud/utils.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) -- cgit v1.2.3