Int -> [a] -> a -http +containers

replicate :: Int -> a -> Seq a
containers Data.Sequence
O(log n). replicate n x is a sequence consisting of n copies of x.
findWithDefault :: a -> Key -> IntMap a -> a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(min(n,W)). The expression (findWithDefault def k map) returns the value at key k or returns def when the key is not an element of the map. > findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x' > findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
singleton :: Key -> a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(1). A map of one element. > singleton 1 'a' == fromList [(1, 'a')] > size (singleton 1 'a') == 1
delete :: Key -> IntSet -> IntSet
containers Data.IntSet
O(min(n,W)). Delete a value in the set. Returns the original set when the value was not present.
insert :: Key -> IntSet -> IntSet
containers Data.IntSet
O(min(n,W)). Add a value to the set. There is no left- or right bias for IntSets.
iterateN :: Int -> (a -> a) -> a -> Seq a
containers Data.Sequence
O(n). Constructs a sequence by repeated application of a function to a seed value. > iterateN n f x = fromList (Prelude.take n (Prelude.iterate f x))
update :: Int -> a -> Seq a -> Seq a
containers Data.Sequence
O(log(min(i,n-i))). Replace the element at the specified position. If the position is out of range, the original sequence is returned.
insert :: Key -> a -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(min(n,W)). Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value, i.e. insert is equivalent to insertWith const. > insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')] > insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')] > insert 5 'x' empty == singleton 5 'x'
insertWith :: (a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(min(n,W)). Insert with a combining function. insertWith f key value mp will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert f new_value old_value. > insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")] > insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] > insertWith (++) 5 "xxx" empty == singleton 5 "xxx"
insertWith' :: (a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
containers Data.IntMap
Deprecated. As of version 0.5, replaced by insertWith. O(log n). Same as insertWith, but the result of the combining function is evaluated to WHNF before inserted to the map.
insertWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
containers Data.IntMap.Lazy
O(min(n,W)). Insert with a combining function. insertWithKey f key value mp will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert f key new_value old_value. > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value > insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")] > insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] > insertWithKey f 5 "xxx" empty == singleton 5 "xxx"
insertWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
containers Data.IntMap.Strict
O(min(n,W)). Insert with a combining function. insertWithKey f key value mp will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert f key new_value old_value. > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value > insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")] > insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] > insertWithKey f 5 "xxx" empty == singleton 5 "xxx" If the key exists in the map, this function is lazy in x but strict in the result of f.
insertWithKey' :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
containers Data.IntMap
Deprecated. As of version 0.5, replaced by insertWithKey. O(log n). Same as insertWithKey, but the result of the combining function is evaluated to WHNF before inserted to the map.
findWithDefault :: Ord k => a -> k -> Map k a -> a
containers Data.Map.Lazy, containers Data.Map.Strict
O(log n). The expression (findWithDefault def k map) returns the value at key k or returns default value def when the key is not in the map. > findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x' > findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
fold :: (a -> b -> b) -> b -> IntMap a -> b
containers Data.IntMap
Deprecated. As of version 0.5, replaced by foldr. O(n). Fold the values in the map using the given right-associative binary operator. This function is an equivalent of foldr and is present for compatibility only.
foldr :: (a -> b -> b) -> b -> IntMap a -> b
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Fold the values in the map using the given right-associative binary operator, such that foldr f z == foldr f z . elems. For example, > elems map = foldr (:) [] map > let f a len = len + (length a) > foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
foldr' :: (a -> b -> b) -> b -> IntMap a -> b
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). A strict version of foldr. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
foldlWithIndex :: (b -> Int -> a -> b) -> b -> Seq a -> b
containers Data.Sequence
foldlWithIndex is a version of foldl that also provides access to the index of each element.
foldrWithIndex :: (Int -> a -> b -> b) -> b -> Seq a -> b
containers Data.Sequence
foldrWithIndex is a version of foldr that also provides access to the index of each element.
(:>) :: Seq a -> a -> ViewR a
containers Data.Sequence
the sequence minus the rightmost element, and the rightmost element

Show more results