(exists proc . list) => boolean
Purpose
Test whether a given property exists in a sequence of lists.
The property is expressed using the n-ary predicate
p. P is first applied to a list consisting
of the first member of each given list. If p returns
truth, exists returns #t immediately. Otherwise it
is applied to a list consisting of the second member of each given
list, etc. If p returns falsity for all sets of members,
exists returns #f.
Arguments
Example
(exists < '(9 1) '(8 2) '(7 3)) => #t
; because (< 1 2 3)
(define (exists p . a*)
(letrec
((carof
(lambda (a)
(map car a)))
(cdrof
(lambda (a)
(map cdr a)))
(exists*
(lambda (a*)
(cond ((null? (car a*)) #f)
(else (or (apply p (carof a*))
(exists* (cdrof a*))))))))
(exists* a*)))
Copyright (C) 2007 Nils M Holm <nmh @ t3x . org>