diff options
author | Arun Isaac | 2021-03-21 16:00:01 +0530 |
---|---|---|
committer | Arun Isaac | 2021-03-21 16:00:01 +0530 |
commit | 553460f7d15e44deda3a7959b89b23bfacc12060 (patch) | |
tree | 7a2fbc14a5ae8f0050aa9a02bc415768f8d88fdc | |
parent | fec5f25f5a6a602a9141d09ad60c58e98f874921 (diff) | |
download | ccwl-553460f7d15e44deda3a7959b89b23bfacc12060.tar.gz ccwl-553460f7d15e44deda3a7959b89b23bfacc12060.tar.lz ccwl-553460f7d15e44deda3a7959b89b23bfacc12060.zip |
Add alist filtering utility function.
* ccwl/ccwl.scm (filter-alist): New function.
(input->tree): Use filter-alist.
-rw-r--r-- | ccwl/ccwl.scm | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 97613a2..be99eb6 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -68,16 +68,21 @@ (define %stdout (output "stdout" #:type 'stdout)) +(define (filter-alist alist) + "Filter ALIST removing entries with #f as the value." + (filter (match-lambda + ((_ . #f) #f) + (_ #t)) + alist)) + (define (input->tree input) "Convert INPUT, an <input> object, to a tree." `(,(input-id input) - ,@(filter identity - (list (and (input-type input) - (cons 'type (input-type input))) - (and (input-label input) - (cons 'label (input-label input))) - (and (not (unspecified-default? (input-default input))) - (cons 'default (input-default input))))) + ,@(filter-alist + `((type . ,(input-type input)) + (label . ,(input-label input)) + (default . ,(and (not (unspecified-default? (input-default input))) + (input-default input))))) ,@(input-other input))) (define-immutable-record-type <step> |