chickadee » srfi-1 » find-tail

find-tail pred clistprocedure

Return the first pair of CLIST whose car satisfies PRED. If no pair does, return false.

find-tail can be viewed as a general-predicate variant of the member function.

Examples:

(find-tail even? '(3 1 37 -8 -5 0 0)) => (-8 -5 0 0)
(find-tail even? '(3 1 37 -5)) => #f
 
;; MEMBER X LIS:
(find-tail (lambda (elt) (equal? x elt)) lis)

In the circular-list case, this procedure "rotates" the list.

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