(a -> a -> b) -> a -> a -> m b
flip f takes its (first) two arguments in the reverse order of f.
(*) `on` f = \x y -> f x * f y.
Typical usage: Data.List.sortBy (compare `on` fst).
Algebraic properties:
* (*) `on` id = (*) (if (*) {¥, const ¥})
* (*) `on` f) `on` g = (*) `on` (f .
* on f . flip on g = flip on (g .
>
Consume the chunks of a lazy Text with a natural right fold.
Consume the chunks of a lazy Text with a strict, tail-recursive, accumulating left fold.
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"
O(n+m). The union with a combining function.
> unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
Lift a binary function to actions.
Promote a function to a monad, scanning the monadic arguments from left to right. For example,
> liftM2 (+) [0,1] [0,2] = [0,2,1,3]
> liftM2 (+) (Just 1) Nothing = Nothing
The deleteBy function behaves like delete, but takes a user-supplied equality predicate.
The non-overloaded version of insert.
zipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two lists to produce the list of corresponding sums.
O(min(n1,n2)). zipWith generalizes zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two sequences to take the sequence of corresponding sums.
O(n+m). The intersection with a combining function.
> intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
chainl p op x parses zero or more occurrences of p, separated by op. Returns a value produced by a left associative application of all functions returned by op. If there are no occurrences of p, x is returned.
chainr p op x parses zero or more occurrences of p, separated by op. Returns a value produced by a right associative application of all functions returned by op. If there are no occurrences of p, x is returned.
Fold over the elements of a structure, associating to the left, but strictly.
foldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
> foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
The list must be finite.
A strict version of foldl.
Show more results