partition p bs == (filter p xs, filter (not . p) xs)
partition p xs == (filter p xs, filter (not . p) xs)
>>> partition (`elem` "aeiou") "Hello World!" ("eoo","Hll Wrld!")
partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
'partition' p xs = ('filter' p xs, 'filter' (not . p) xs)
partitionWithKey (\ k _ -> k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b") partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
>>> 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