- collect-any pred? #!optional (sentinel #f)procedure
Returns a collector that will return #t if any item it encounters satisfies pred?. Returns early if pred? is satisfied, but will iterate across the entirety of the data if pred? isn't satisfied by any of the items.
(import transducers) (transduce list-fold (inspect (lambda (x) (if (odd? x) (print x " is odd!") (print x " is not odd!")))) (collect-any odd?) (list 2 4 6 8)) ; 2 is not odd! ; 4 is not odd! ; 6 is not odd! ; 8 is not odd! ; => #f (transduce list-fold (inspect (lambda (x) (if (odd? x) (print x " is odd!") (print x " is not odd!")))) (collect-any odd?) (list 2 1 6 8)) ; 2 is not odd! ; 1 is odd! ; => #t