/usr/lib/s9fes/for-all.scm is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2009
; See the LICENSE file of the S9fES package for terms of use
;
; (for-all procedure list ...) ==> object
;
; Test whether all members of a sequence of N lists have a given
; property. The property is expressed using an N-ary predicate P,
; which is given in the procedure argument. P is applied to a list
; consisting of the first member of each given list. If P returns
; truth, it is applied to a list consisting of the second member of
; each given list, etc. If P returns falsity for any set of members,
; FOR-ALL returns #F. If only one set of members is left to check,
; FOR-ALL returns the value of P applied to this final set.
; When the LISTs are empty, FOR-ALL returns #T.
;
; Example: (for-all < '(1 7) '(2 8) '(3 9)) ==> #t
; ; because (< 1 2 3) and (< 7 8 9)
(define (for-all p . a*)
(letrec
((car-of
(lambda (a)
(map car a)))
(cdr-of
(lambda (a)
(map cdr a)))
(any-null
(lambda (a)
(memq '() a)))
(for-all*
(lambda (a*)
(cond ((any-null a*) #t)
((any-null (cdr-of a*))
(apply p (car-of a*)))
(else
(and (apply p (car-of a*))
(for-all* (cdr-of a*))))))))
(for-all* a*)))
|