foldl -text

foldl :: (a -> b -> a) -> a -> [b] -> a
base Prelude, base Data.List
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.
foldl :: Foldable t => (a -> b -> a) -> a -> t b -> a
base Data.Foldable
foldl :: (a -> Char -> a) -> a -> ByteString -> a
bytestring Data.ByteString.Char8, bytestring Data.ByteString.Lazy.Char8
foldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from left to right.
foldl :: (a -> Key -> a) -> a -> IntSet -> a
containers Data.IntSet
O(n). Fold the elements in the set using the given left-associative binary operator, such that foldl f z == foldl f z . toAscList. For example, > toDescList set = foldl (flip (:)) [] set
foldl :: (a -> Word8 -> a) -> a -> ByteString -> a
bytestring Data.ByteString.Lazy
foldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from left to right.
foldl :: (a -> Word8 -> a) -> a -> ByteString -> a
bytestring Data.ByteString
foldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from left to right. This function is subject to array fusion.
foldl :: (a -> b -> a) -> a -> IntMap b -> a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Fold the values in the map using the given left-associative binary operator, such that foldl f z == foldl f z . elems. For example, > elems = reverse . foldl (flip (:)) [] > let f len a = len + (length a) > foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
foldl :: (a -> b -> a) -> a -> Map k b -> a
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). Fold the values in the map using the given left-associative binary operator, such that foldl f z == foldl f z . elems. For example, > elems = reverse . foldl (flip (:)) [] > let f len a = len + (length a) > foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
foldl :: (a -> b -> a) -> a -> Set b -> a
containers Data.Set
O(n). Fold the elements in the set using the given left-associative binary operator, such that foldl f z == foldl f z . toAscList. For example, > toDescList set = foldl (flip (:)) [] set
package foldl
package
This library provides strict left folds that stream in constant memory, and you can combine folds using Applicative style to derive new folds.  Derived folds still traverse the container just once and are often as efficient as hand-written folds. Version 1.0.0
foldl1 :: (a -> a -> a) -> [a] -> a
base Prelude, base Data.List
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty lists.
foldl' :: (a -> b -> a) -> a -> [b] -> a
base Data.List
A strict version of foldl.
foldl' :: Foldable t => (a -> b -> a) -> a -> t b -> a
base Data.Foldable
Fold over the elements of a structure, associating to the left, but strictly.
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
base Data.Foldable
foldl1' :: (a -> a -> a) -> [a] -> a
base Data.List
A strict version of foldl1
foldlM :: (Foldable t, Monad m) => (a -> b -> m a) -> a -> t b -> m a
base Data.Foldable
Monadic fold over the elements of a structure, associating to the left, i.e. from left to right.
foldl' :: (a -> Char -> a) -> a -> ByteString -> a
bytestring Data.ByteString.Char8, bytestring Data.ByteString.Lazy.Char8
'foldl\'' is like foldl, but strict in the accumulator.
foldl' :: (a -> Key -> a) -> a -> IntSet -> a
containers Data.IntSet
O(n). A strict version of foldl. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a
bytestring Data.ByteString.Lazy
'foldl\'' is like foldl, but strict in the accumulator.
foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a
bytestring Data.ByteString
'foldl\'' is like foldl, but strict in the accumulator. However, for ByteStrings, all left folds are strict in the accumulator.
foldl' :: (a -> b -> a) -> a -> IntMap b -> a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). A strict version of foldl. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
foldl' :: (a -> b -> a) -> a -> Map k b -> a
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). A strict version of foldl. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
foldl' :: (a -> b -> a) -> a -> Set b -> a
containers Data.Set
O(n). A strict version of foldl. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
foldl1 :: (Char -> Char -> Char) -> ByteString -> Char
bytestring Data.ByteString.Char8, bytestring Data.ByteString.Lazy.Char8
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings.
foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
bytestring Data.ByteString.Lazy
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. This function is subject to array fusion.
foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
bytestring Data.ByteString
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. This function is subject to array fusion. An exception will be thrown in the case of an empty ByteString.
foldl1' :: (Char -> Char -> Char) -> ByteString -> Char
bytestring Data.ByteString.Lazy.Char8
'foldl1\'' is like foldl1, but strict in the accumulator.
foldl1' :: (Char -> Char -> Char) -> ByteString -> Char
bytestring Data.ByteString.Char8
A strict version of foldl1
foldl1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
bytestring Data.ByteString.Lazy
'foldl1\'' is like foldl1, but strict in the accumulator.
foldl1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
bytestring Data.ByteString
'foldl1\'' is like foldl1, but strict in the accumulator. An exception will be thrown in the case of an empty ByteString.
foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> a
bytestring Data.ByteString.Lazy
Consume the chunks of a lazy ByteString with a strict, tail-recursive, accumulating left fold.
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.
foldlWithKey :: (a -> Key -> b -> a) -> a -> IntMap b -> a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Fold the keys and values in the map using the given left-associative binary operator, such that foldlWithKey f z == foldl (\z' (kx, x) -> f z' kx x) z . toAscList. For example, > keys = reverse . foldlWithKey (\ks k x -> k:ks) [] > let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" > foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"
foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). Fold the keys and values in the map using the given left-associative binary operator, such that foldlWithKey f z == foldl (\z' (kx, x) -> f z' kx x) z . toAscList. For example, > keys = reverse . foldlWithKey (\ks k x -> k:ks) [] > let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" > foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"
foldlWithKey' :: (a -> Key -> b -> a) -> a -> IntMap b -> a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). A strict version of foldlWithKey. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
foldlWithKey' :: (a -> k -> b -> a) -> a -> Map k b -> a
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). A strict version of foldlWithKey. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.
gfoldl :: Data a => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a
base Data.Data
gfoldlAccum :: Data d => (forall e r. Data e => a -> c (e -> r) -> e -> (a, c r)) -> (forall g. a -> g -> (a, c g)) -> a -> d -> (a, c d)
syb Data.Generics.Twins
gfoldl with accumulation
unfoldl :: (b -> Maybe (b, a)) -> b -> Seq a
containers Data.Sequence
unfoldl f x is equivalent to reverse (unfoldr (fmap swap . f) x).