manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Filtering and Partitioning

Filtering means to collect all elements from a list which satisfy a specific condition. Partitioning a list means to make two groups of list elements, one which contains the elements satisfying a condition, and the other for the elements which don’t.

The filter and filter! functions are implemented in the Guile core, See section List Modification.

Scheme Procedure: partition pred lst
Scheme Procedure: partition! pred lst

Split lst into those elements which do and don’t satisfy the predicate pred.

The return is two values (see section Returning and Accepting Multiple Values), the first being a list of all elements from lst which satisfy pred, the second a list of those which do not.

The elements in the result lists are in the same order as in lst but the order in which the calls (pred elem) are made on the list elements is unspecified.

partition does not change lst, but one of the returned lists may share a tail with it. partition! may modify lst to construct its return.

Scheme Procedure: remove pred lst
Scheme Procedure: remove! pred lst

Return a list containing all elements from lst which do not satisfy the predicate pred. The elements in the result list have the same order as in lst. The order in which pred is applied to the list elements is not specified.

remove! is allowed, but not required to modify the structure of the input list.

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

This document was generated on April 20, 2013 using texi2html 5.0.

© 2000-2019
Individual documents may contain additional copyright information.