www.delorie.com/gnu/docs/guile/guile_448.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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 lst
Return the first element of lst which satisfies the predicate pred and #f if no such element is found.

Scheme Procedure: find-tail pred lst
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 lst
Scheme Procedure: take-while! pred lst
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 lst
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 lst1 lst2 ...
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 lst1 lst2 ...
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 lst1 lst2 ...
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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003