Next: , Previous: SRFI-1 Filtering and Partitioning, Up: SRFI-1


39.3.7 Searching

The procedures for searching elements in lists either accept a predicate or a comparison object for determining which elements are to be searched.

— Scheme Procedure: find pred clist

Return the first element of lst which satisfies the predicate pred and #f if no such element is found.

— Scheme Procedure: find-tail pred clist

Return the first pair of lst whose car satisfies the predicate pred and #f if no such element is found.

— Scheme Procedure: take-while pred ls
— Scheme Procedure: take-while! pred ls

Return the longest initial prefix of lst whose elements all satisfy the predicate pred.

take-while! is allowed, but not required to modify the input list while producing the result.

— Scheme Procedure: drop-while pred clist

Drop the longest initial prefix of lst whose elements all satisfy the predicate pred.

— Scheme Procedure: span pred lst
— Scheme Procedure: span! pred lst
— Scheme Procedure: break pred lst
— Scheme Procedure: break! pred lst

span splits the list lst into the longest initial prefix whose elements all satisfy the predicate pred, and the remaining tail. break inverts the sense of the predicate.

span! and break! are allowed, but not required to modify the structure of the input list lst in order to produce the result.

— Scheme Procedure: any pred ls [lists...]

Apply pred across the lists and return a true value if the predicate returns true for any of the list elements(s); return #f otherwise. The true value returned is always the result of the first successful application of pred.

— Scheme Procedure: every pred ls [lists...]

Apply pred across the lists and return a true value if the predicate returns true for every of the list elements(s); return #f otherwise. The true value returned is always the result of the final successful application of pred.

— Scheme Procedure: list-index pred clist1 [rest...]

Return the index of the leftmost element that satisfies pred.

— Scheme Procedure: member x lst [=]

Return the first sublist of lst whose car is equal to x. If x does no appear in lst, return #f. Equality is determined by the equality predicate =, or equal? if = is not given.