Next: SRFI-1 Deleting, Previous: SRFI-1 Filtering and Partitioning, Up: SRFI-1
The procedures for searching elements in lists either accept a predicate or a comparison object for determining which elements are to be searched.
Return the first element of lst which satisfies the predicate pred and
#f
if no such element is found.
Return the first pair of lst whose car satisfies the predicate pred and
#f
if no such element is found.
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.
Drop the longest initial prefix of lst whose elements all satisfy the predicate pred.
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!
andbreak!
are allowed, but not required to modify the structure of the input list lst in order to produce the result.Note that the name
break
conflicts with thebreak
binding established bywhile
(see while do). Applications wanting to usebreak
from within awhile
loop will need to make a new define under a different name.
Test whether any set of elements from lst1 ... lstN satisfies pred. If so the return value is the return from the successful pred call, or if not the return is
#f
.Each pred call is
(
pred elem1...
elemN)
taking an element from each lst. The calls are made successively for the first, second, etc elements of the lists, stopping when pred returns non-#f
, or when the end of the shortest list is reached.The pred call on the last set of elements (ie. when the end of the shortest list has been reached), if that point is reached, is a tail call.
Test whether every set of elements from lst1 ... lstN satisfies pred. If so the return value is the return from the final pred call, or if not the return is
#f
.Each pred call is
(
pred elem1...
elemN)
taking an element from each lst. The calls are made successively for the first, second, etc elements of the lists, stopping if pred returns#f
, or when the end of any of the lists is reached.The pred call on the last set of elements (ie. when the end of the shortest list has been reached) is a tail call.
If one of lst1 ... lstN is empty then no calls to pred are made, and the return is
#t
.
Return the index of the first set of elements, one from each of lst1...lstN, which satisfies pred.
pred is called as
(
predelem1 ... elemN)
. Searching stops when the end of the shortest lst is reached. The return index starts from 0 for the first set of elements. If no set of elements pass then the return is#f
.(list-index odd? '(2 4 6 9)) => 3 (list-index = '(1 2 3) '(3 1 2)) => #f
Return the first sublist of lst whose car is equal to x. If x does not appear in lst, return
#f
.Equality is determined by
equal?
, or by the equality predicate = if given. = is called(=
xelem)
, ie. with the given x first, so for example to find the first element greater than 5,(member 5 '(3 5 1 7 2 9) <) => (7 2 9)This version of
member
extends the coremember
(see List Searching) by accepting an equality predicate.