List.partition
partitioncondition
Group: Selections
Documentation
Partitions the list into lists of elements which satisfy a given condition and ones that do not. Returns a Pair
whose first
element is the list of elements satisfying the predicate and the second
element is a list of elements which did not satisfy it. The relative order of elements kept in each returned list is the same as in the input.
Arguments
condition
: AFilter_Condition
or a predicate function to test each element.
Examples
Splitting a list into even and odd elements.
(Cons 1 (Cons 2 (Cons 3 Nil))).partition (x -> x % 2 == 0) == (Pair (Cons 2 Nil) (Cons 1 (Cons 3 Nil)))