foldl1

A variant of foldl that has no base case, and thus may only be applied to non-empty structures. This function is non-total and will raise a runtime exception if the structure happens to be empty.
foldl1 f = foldl1 f . toList

Examples

Basic usage:
>>> foldl1 (+) [1..4]
10
>>> foldl1 (+) []
*** Exception: Prelude.foldl1: empty list
>>> foldl1 (+) Nothing
*** Exception: foldl1: empty structure
>>> foldl1 (-) [1..4]
-8
>>> foldl1 (&&) [True, False, True, True]
False
>>> foldl1 (||) [False, False, True, True]
True
>>> foldl1 (+) [1..]
* Hangs forever *
A variant of foldlMap1 where the leftmost element maps to itself.
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty lists. Note that unlike foldl, the accumulated value must be of the same type as the list elements.
>>> foldl1 (+) [1..4]
10

>>> foldl1 (+) []
*** Exception: Prelude.foldl1: empty list

>>> foldl1 (-) [1..4]
-8

>>> foldl1 (&&) [True, False, True, True]
False

>>> foldl1 (||) [False, False, True, True]
True

>>> foldl1 (+) [1..]
* Hangs forever *
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. An exception will be thrown in the case of an empty ByteString.
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings.
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings.
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ShortByteStrings. An exception will be thrown in the case of an empty ShortByteString.
O(n) A variant of foldl that has no starting value argument, and thus must be applied to a non-empty Text.
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty Streams. Properties
foldl1 f . stream = foldl1 f
A strict left fold with no starting value. Returns Nothing when the stream is empty. Subject to fusion
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings.
foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty ByteStrings. An exception will be thrown in the case of an empty ByteString.
A variant of foldl that has no base case, and thus may only be applied to non-empty structures.
foldl1 f = foldl1 f . toList
O(n) A variant of foldl that has no starting value argument, and thus must be applied to a non-empty Text. Subject to fusion.
O(n) Left fold on non-empty vectors
O(n) Left fold on non-empty vectors
O(n) Left fold on non-empty vectors
O(n) Left fold on non-empty vectors
Reduces the characters of the ShortText with the binary operator.
>>> foldl1 max "abcdcba"
'd'
>>> foldl1 const "abcd"
'a'
>>> foldl1 (flip const) "abcd"
'd'
Note: Will throw an error exception if index is out of bounds.
A variant of foldl with no base case. Requires at least 1 list element.
O(n) A variant of foldl that has no starting value argument, and thus must be applied to a non-empty JSString. Subject to fusion.