1\DOC partition
2
3\TYPE {partition : ('a -> bool) -> 'a list -> 'a list * 'a list}
4
5\SYNOPSIS
6Split a list by a predicate.
7
8\KEYWORDS
9list
10
11\DESCRIBE
12An invocation {partition P l} divides {l} into a pair of lists {(l1,l2)}.
13{P} holds of each element of {l1}, and {P} does not hold of any element of
14{l2}.
15
16\FAILURE
17If applying {P} to any element of {l} results in failure.
18
19\EXAMPLE
20{
21- partition (fn i => i mod 2 = 0) [1,2,3,4,5,6,7,8,9];
22> val it = ([2, 4, 6, 8], [1, 3, 5, 7, 9]) : int list * int list
23
24- partition (fn _ => true) [1,2,3];
25> val it = ([1, 2, 3], []) : int list * int list
26
27- partition (fn _ => raise Fail "") ([]:int list);
28> val it = ([], []) : int list * int list
29
30- partition (fn _ => raise Fail "") [1];
31! Uncaught exception:
32! Fail  ""
33}
34
35
36\SEEALSO
37Lib.split_after, Lib.pluck.
38\ENDDOC
39