partition

partition :: (a -> Bool) -> [a] -> ([a], [a])
base Data.List
The partition function takes a predicate a list and returns the pair of lists of elements which do and do not satisfy the predicate, respectively; i.e., > partition p xs == (filter p xs, filter (not . p) xs)
partition :: (Char -> Bool) -> Text -> (Text, Text)
text Data.Text, text Data.Text.Lazy
O(n) The partition function takes a predicate and a Text, and returns the pair of Texts with elements which do and do not satisfy the predicate, respectively; i.e. > partition p t == (filter p t, filter (not . p) t)
partition :: (Key -> Bool) -> IntSet -> (IntSet, IntSet)
containers Data.IntSet
O(n). partition the set according to some predicate.
partition :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
bytestring Data.ByteString, bytestring Data.ByteString.Lazy
O(n) The partition function takes a predicate a ByteString and returns the pair of ByteStrings with elements which do and do not satisfy the predicate, respectively; i.e., > partition p bs == (filter p xs, filter (not . p) xs)
partition :: (a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also split. > 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 :: (a -> Bool) -> Map k a -> (Map k a, Map k a)
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). Partition the map according to a predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also split. > 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 :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
containers Data.Sequence
O(n). The partition function takes a predicate p and a sequence xs and returns sequences of those elements which do and do not satisfy the predicate.
partition :: (a -> Bool) -> Set a -> (Set a, Set a)
containers Data.Set
O(n). Partition the set into two sets, one with all elements that satisfy the predicate and one with all elements that don't satisfy the predicate. See also split.
partitionEithers :: [Either a b] -> ([a], [b])
base Data.Either
Partitions a list of Either into two lists All the Left elements are extracted, in order, to the first component of the output. Similarly the Right elements are extracted to the second component of the output.
partitionWithKey :: (Key -> a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also split. > 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")])
partitionWithKey :: (k -> a -> Bool) -> Map k a -> (Map k a, Map k a)
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). Partition the map according to a predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also split. > 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")])
package data-partition
package