Reputation: 2910
There is some
in clojure
, which can be expressed in chicken scheme
as following:
(define (some pred coll)
(lazy-head (lazy-filter pred (list->lazy-seq coll))))
Is there something built-in?
Upvotes: 0
Views: 41
Reputation: 43842
Take a look at find
from SRFI 1—it works just like your implementation:
(find even? '(3 1 4 1 5 9)) ; => 4
Note, however, that is is slightly different from Clojure's some
: Clojure returns the value of pred
applied to the element, whereas find
returns the element itself.
See also any
, also from SRFI 1, which is preferable if you don't need the value, just a check for existence.
Upvotes: 3