insert -fgl

insert :: HashTable key val -> key -> val -> IO ()
base Data.HashTable
Inserts a key/value mapping into the hash table. Note that insert doesn't remove the old entry from the table - the behaviour is like an association list, the most-recently-inserted mapping for a key in the table. The reason for this is to keep insert as efficient as possible. If you need to update a mapping, then we provide update.
insert :: Ord a => a -> [a] -> [a]
base Data.List
The insert function takes an element and a list and inserts the element into the list at the last position or equal to the next element. In particular, if the list is sorted before the call, the result will also be sorted. It is a special case of insertBy, which allows the programmer to supply their own comparison function.
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.
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'
insert :: Ord a => a -> Set a -> Set a
containers Data.Set
O(log n). Insert an element in a set. If the set already contains an element equal to the given value, it is replaced with the new value.
insert :: Ord k => k -> a -> Map k a -> Map k a
containers Data.Map.Lazy, containers Data.Map.Strict
O(log n). Insert a new key and value in the map. If the key is already present in the map, the associated value is replaced with the supplied value. 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'
insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
base Data.List
The non-overloaded version of insert.
insertHeader :: HasHeaders a => HeaderSetter a
HTTP Network.HTTP.Headers
insertHeader hdr val x inserts a header with the given header name and value. Does not check for existing headers with same name, allowing duplicates to be introduce (use replaceHeader if you want to avoid this.)
insertHeaderIfMissing :: HasHeaders a => HeaderSetter a
HTTP Network.HTTP.Headers
insertHeaderIfMissing hdr val x adds the new header only if no previous header with name hdr exists in x.
insertHeaders :: HasHeaders a => [Header] -> a -> a
HTTP Network.HTTP.Headers
insertHeaders hdrs x appends multiple headers to x's existing set.
insertLookupWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> (Maybe a, IntMap a)
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(min(n,W)). The expression (insertLookupWithKey f k x map) is a pair (lookup k map) and the second element equal to (insertWithKey f k x map). > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value > insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) > insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")]) > insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx") This is how to define insertLookup using insertLookupWithKey: > let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t > insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")]) > insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])
insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)
containers Data.Map.Lazy, containers Data.Map.Strict
O(log n). Combines insert operation with old value retrieval. The expression (insertLookupWithKey f k x map) is a pair map</tt>) and the second element equal to (insertWithKey f k x map). > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value > insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) > insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")]) > insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx") This is how to define insertLookup using insertLookupWithKey: > let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t > insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")]) > insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])
insertLookupWithKey' :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)
containers Data.Map
Deprecated. As of version 0.5, replaced by insertLookupWithKey. O(log n). Same as insertLookupWithKey, but the value being inserted to the map is evaluated to WHNF beforehand.
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 :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
containers Data.Map.Lazy, containers Data.Map.Strict
O(log n). Insert with a function, combining new value and old value. 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 the pair (key, 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.
insertWith' :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
containers Data.Map
Deprecated. As of version 0.5, replaced by insertWith. O(log n). Same as insertWith, but the value being inserted to the map is evaluated to WHNF beforehand. For example, to update a counter: > insertWith' (+) k 1 m
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 :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a
containers Data.Map.Lazy, containers Data.Map.Strict
O(log n). Insert with a function, combining key, new value and old value. 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 the pair (key,f key new_value old_value). Note that the key passed to f is the same key passed to insertWithKey. > 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"

Show more results