utils: Add 'every*'.

* guix/build/gnu-build-system.scm (every*): Move to...
* guix/build/utils.scm (every*): ... here.  New procedure.
This commit is contained in:
Ludovic Courtès 2015-10-03 12:28:58 +02:00
parent 29aca449c7
commit 57aff6476e
2 changed files with 14 additions and 12 deletions

View File

@ -409,18 +409,6 @@ makefiles."
strip-directories))) strip-directories)))
outputs)))) outputs))))
(define (every* pred lst)
"This is like 'every', but process all the elements of LST instead of
stopping as soon as PRED returns false. This is useful when PRED has side
effects, such as displaying warnings or error messages."
(let loop ((lst lst)
(result #t))
(match lst
(()
result)
((head . tail)
(loop tail (and (pred head) result))))))
(define* (validate-runpath #:key (define* (validate-runpath #:key
(validate-runpath? #t) (validate-runpath? #t)
(elf-directories '("lib" "lib64" "libexec" (elf-directories '("lib" "lib64" "libexec"

View File

@ -59,10 +59,12 @@
list->search-path-as-string list->search-path-as-string
which which
every*
alist-cons-before alist-cons-before
alist-cons-after alist-cons-after
alist-replace alist-replace
modify-phases modify-phases
with-atomic-file-replacement with-atomic-file-replacement
substitute substitute
substitute* substitute*
@ -454,6 +456,18 @@ PROGRAM could not be found."
;;; phases. ;;; phases.
;;; ;;;
(define (every* pred lst)
"This is like 'every', but process all the elements of LST instead of
stopping as soon as PRED returns false. This is useful when PRED has side
effects, such as displaying warnings or error messages."
(let loop ((lst lst)
(result #t))
(match lst
(()
result)
((head . tail)
(loop tail (and (pred head) result))))))
(define* (alist-cons-before reference key value alist (define* (alist-cons-before reference key value alist
#:optional (key=? equal?)) #:optional (key=? equal?))
"Insert the KEY/VALUE pair before the first occurrence of a pair whose key "Insert the KEY/VALUE pair before the first occurrence of a pair whose key