chickadee » srfi-116 » ifind-tail

ifind-tail pred ilistprocedure

Return the first ipair of ilist whose icar satisfies pred. If no ipair does, return false.

ifind-tail can be viewed as a general-predicate variant of the imember function.

Examples:

(ifind-tail even? (iq 3 1 37 -8 -5 0 0)) ;=> (-8 -5 0 0)
(ifind-tail even? (iq 3 1 37 -5))        ;=> #f

;; IMEMBER X LIS:
(ifind-tail (lambda (elt) (equal? x elt)) lis)

ifind-tail is essentially idrop-while, where the sense of the predicate is inverted: ifind-tail searches until it finds an element satisfying the predicate; idrop-while searches until it finds an element that doesn't satisfy the predicate.