Alternative f => [f a] -> f a +containers

unions :: [IntMap a] -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
The union of a list of maps. > unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] > == fromList [(3, "b"), (5, "a"), (7, "C")] > unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])] > == fromList [(3, "B3"), (5, "A3"), (7, "C")]
unionsWith :: (a -> a -> a) -> [IntMap a] -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
The union of a list of maps, with a combining operation. > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]
unions :: Ord a => [Set a] -> Set a
containers Data.Set
The union of a list of sets: (unions == foldl union empty).
Node :: a -> Forest a -> Tree a
containers Data.Tree
deleteMax :: IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(min(n,W)). Delete the maximal key. Returns an empty map if the map is empty. Note that this is a change of behaviour for consistency with Map  versions prior to 0.5 threw an error if the IntMap was already empty.
deleteMin :: IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(min(n,W)). Delete the minimal key. Returns an empty map if the map is empty. Note that this is a change of behaviour for consistency with Map  versions prior to 0.5 threw an error if the IntMap was already empty.
reverse :: Seq a -> Seq a
containers Data.Sequence
O(n). The reverse of a sequence.
deleteMax :: Set a -> Set a
containers Data.Set
O(log n). Delete the maximal element. Returns an empty set if the set is empty.
deleteMin :: Set a -> Set a
containers Data.Set
O(log n). Delete the minimal element. Returns an empty set if the set is empty.
filter :: (a -> Bool) -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Filter all values that satisfy some predicate. > filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" > filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty > filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty
updateMax :: (a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Strict
O(log n). Update the value at the maximal key. > updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] > updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
updateMax :: (a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Lazy
O(min(n,W)). Update the value at the maximal key. > updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] > updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
updateMin :: (a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Strict
O(log n). Update the value at the minimal key. > updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] > updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
updateMin :: (a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Lazy
O(min(n,W)). Update the value at the minimal key. > updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] > updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
(\\) :: IntMap a -> IntMap b -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
Same as difference.
difference :: IntMap a -> IntMap b -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). Difference between two maps (based on keys). > difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"
intersection :: IntMap a -> IntMap b -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). The (left-biased) intersection of two maps (based on keys). > intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"
union :: IntMap a -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). The (left-biased) union of two maps. It prefers the first map when duplicate keys are encountered, i.e. (union == unionWith const). > union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]
scanl1 :: (a -> a -> a) -> Seq a -> Seq a
containers Data.Sequence
scanl1 is a variant of scanl that has no starting value argument: > scanl1 f (fromList [x1, x2, ...]) = fromList [x1, x1 `f` x2, ...]
scanr1 :: (a -> a -> a) -> Seq a -> Seq a
containers Data.Sequence
scanr1 is a variant of scanr that has no starting value argument.
sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a
containers Data.Sequence
O(n log n). sortBy sorts the specified Seq according to the specified comparator. The sort is stable. If stability is not required, unstableSortBy can be considerably faster, and in particular uses less memory.
unstableSortBy :: (a -> a -> Ordering) -> Seq a -> Seq a
containers Data.Sequence
O(n log n). A generalization of unstableSort, unstableSortBy takes an arbitrary comparator and sorts the specified sequence. The sort is not stable. This algorithm is frequently faster and uses less memory than sortBy, and performs extremely well -- frequently twice as fast as sortBy -- when the sequence is already nearly sorted.
dropWhileL :: (a -> Bool) -> Seq a -> Seq a
containers Data.Sequence
O(i) p xs</tt> returns the suffix remaining after takeWhileL p xs.
dropWhileR :: (a -> Bool) -> Seq a -> Seq a
containers Data.Sequence
O(i) p xs</tt> returns the prefix remaining after takeWhileR p xs. dropWhileR p xs is equivalent to reverse (dropWhileL p (reverse xs)).
filter :: (a -> Bool) -> Seq a -> Seq a
containers Data.Sequence
O(n). The filter function takes a predicate p and a sequence xs and returns a sequence of those elements which satisfy the predicate.
takeWhileL :: (a -> Bool) -> Seq a -> Seq a
containers Data.Sequence
O(i) applied to a predicate p and a sequence xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.
takeWhileR :: (a -> Bool) -> Seq a -> Seq a
containers Data.Sequence
O(i) applied to a predicate p and a sequence xs, returns the longest suffix (possibly empty) of xs of elements that satisfy p. takeWhileR p xs is equivalent to reverse (takeWhileL p (reverse xs)).
(<|) :: a -> Seq a -> Seq a
containers Data.Sequence
O(1). Add an element to the left end of a sequence. Mnemonic: a triangle with the single element at the pointy end.
drop :: Int -> Seq a -> Seq a
containers Data.Sequence
O(log(min(i,n-i))). Elements of a sequence after the first i. If i is negative, drop i s yields the whole sequence. If the sequence contains fewer than i elements, the empty sequence is returned.
take :: Int -> Seq a -> Seq a
containers Data.Sequence
O(log(min(i,n-i))). The first i elements of a sequence. If i is negative, take i s yields the empty sequence. If the sequence contains fewer than i elements, the whole sequence is returned.
(|>) :: Seq a -> a -> Seq a
containers Data.Sequence
O(1). Add an element to the right end of a sequence. Mnemonic: a triangle with the single element at the pointy end.
(><) :: Seq a -> Seq a -> Seq a
containers Data.Sequence
O(log(min(n1,n2))). Concatenate two sequences.
filter :: (a -> Bool) -> Set a -> Set a
containers Data.Set
O(n). Filter all elements that satisfy the predicate.
deleteAt :: Int -> Set a -> Set a
containers Data.Set
O(log n). Delete the element at index, i.e. by its zero-based index in the sorted sequence of elements. If the index is out of range (less than zero, greater or equal to size of the set), error is called. > deleteAt 0 (fromList [5,3]) == singleton 5 > deleteAt 1 (fromList [5,3]) == singleton 3 > deleteAt 2 (fromList [5,3]) Error: index out of range > deleteAt (-1) (fromList [5,3]) Error: index out of range
filterWithKey :: (Key -> a -> Bool) -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Filter all keys/values that satisfy some predicate. > filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
updateMaxWithKey :: (Key -> a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Strict
O(log n). Update the value at the maximal key. > updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] > updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
updateMaxWithKey :: (Key -> a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Lazy
O(min(n,W)). Update the value at the maximal key. > updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] > updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
updateMinWithKey :: (Key -> a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Strict
O(log n). Update the value at the minimal key. > updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] > updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
updateMinWithKey :: (Key -> a -> Maybe a) -> IntMap a -> IntMap a
containers Data.IntMap.Lazy
O(min(n,W)). Update the value at the minimal key. > updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] > updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
mapKeys :: (Key -> Key) -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n*min(n,W)). mapKeys f s is the map obtained by applying f to each key of s. The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the value at the greatest of the original keys is retained. > mapKeys (+ 1) (fromList [(5,"a"), (3,"b")]) == fromList [(4, "b"), (6, "a")] > mapKeys (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "c" > mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "c"

Show more results