on master help sign in
Improve documentation for "partition"
a5a59b1Evan Czaplicki
libraries/List.elm+7−1
@@ -163,7 +163,13 @@ maximum = foldl1 max
163minimum : [comparable] -> comparable
163minimum : [comparable] -> comparable
164minimum = foldl1 min
164minimum = foldl1 min
165
165
166−{-| Split a list based on the predicate. -}
166+{-| Partition a list based on a predicate. The first list contains all values
167+that satisfy the predicate, and the second list contains all the value that do
168+not.
169+
170+ partition (\x -> x < 3) [0..5] == ([0,1,2], [3,4,5])
171+ partition isEven [0..5] == ([0,2,4], [1,3,5])
172+-}
167partition : (a -> Bool) -> [a] -> ([a],[a])
173partition : (a -> Bool) -> [a] -> ([a],[a])
168partition pred lst =
174partition pred lst =
169 case lst of
175 case lst of