partition p xs == (filter p xs, filter (not . p) xs)
>>> partition (`elem` "aeiou") "Hello World!" ("eoo","Hll Wrld!")
>>> partition even [1..10] ([2,4,6,8,10],[1,3,5,7,9])
>>> partition (< 5) [1..10] ([1,2,3,4],[5,6,7,8,9,10])
'partition' p xs = ('filter' p xs, 'filter' (not . p) xs)
>>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ] >>> partitionEithers list (["foo","bar","baz"],[3,7])The pair returned by partitionEithers x should be the same pair as (lefts x, rights x):
>>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ] >>> partitionEithers list == (lefts list, rights list) True