(a -> b -> c -> d) -> f a -> f b -> f c -> f d
Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2).
Lift a ternary function to actions.
O(min(n1,n2,n3)). zipWith3 takes a function which combines three elements, as well as three sequences and returns a sequence of their point-wise combinations, analogous to zipWith.
The zipWith3 function takes a function which combines three elements, as well as three lists and returns a list of their point-wise combination, analogous to zipWith.
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"
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.