aboutsummaryrefslogtreecommitdiff
path: root/guix/utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-10-01 10:19:14 +0200
committerLudovic Courtès <ludo@gnu.org>2014-10-05 21:57:19 +0200
commit5e1103821a566e55c848c8fa323d07801cce6ab7 (patch)
tree866d0ce8fe5307eac5782f397067cfa3790eb0c1 /guix/utils.scm
parentb72a312c307131703bd65a9e2db04cd9b35d0fbe (diff)
downloadgnu-guix-5e1103821a566e55c848c8fa323d07801cce6ab7.tar
gnu-guix-5e1103821a566e55c848c8fa323d07801cce6ab7.tar.gz
utils: Add 'strip-keyword-arguments'.
* guix/utils.scm (strip-keyword-arguments): New procedure. * tests/utils.scm ("strip-keyword-arguments"): New test.
Diffstat (limited to 'guix/utils.scm')
-rw-r--r--guix/utils.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/guix/utils.scm b/guix/utils.scm
index 34a5e6c971..2814247a68 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -48,6 +48,7 @@
compile-time-value
fcntl-flock
memoize
+ strip-keyword-arguments
default-keyword-arguments
substitute-keyword-arguments
@@ -424,6 +425,21 @@ exception if it's already taken."
(hash-set! cache args results)
(apply values results)))))))
+(define (strip-keyword-arguments keywords args)
+ "Remove all of the keyword arguments listed in KEYWORDS from ARGS."
+ (let loop ((args args)
+ (result '()))
+ (match args
+ (()
+ (reverse result))
+ (((? keyword? kw) arg . rest)
+ (loop rest
+ (if (memq kw keywords)
+ result
+ (cons* arg kw result))))
+ ((head . tail)
+ (loop tail (cons head result))))))
+
(define (default-keyword-arguments args defaults)
"Return ARGS augmented with any keyword/value from DEFAULTS for
keywords not already present in ARGS."