on master help sign in
Improve documentation for "partition"
commita5a59b159fa97ca8cd79f8c4804efbab08a8757c authorEvan Czaplicki <info@elm-lang.org> dateThu 17 Apr 2014, 14:58 (13 years ago) parent663f565
1 file changed+7−1
libraries/List.elm+7−1
libraries/List.elm+7−1
@@ -163,7 +163,13 @@ maximum = foldl1 max
163163minimum : [comparable] -> comparable
164164minimum = foldl1 min
165165
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+-}
167173partition : (a -> Bool) -> [a] -> ([a],[a])
168174partition pred lst =
169175 case lst of