ZVON > References > Haskell reference
| Indexes | Syntax | >> Prelude << | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random

Module: Prelude
Function: foldl
Type: (a -> b -> a) -> a -> [b] -> a
Description: it takes the second argument and the first item of the list and applies the function to them, then feeds the function with this result and the second argument and so on. See scanl for intermediate results.
Related: foldl1, foldr, foldr1, scanl, scanl1, scanr, scanr1

Example 1

Input: foldl (/) 64 [4,2,4]

Output: 2.0

Example 2

Input: foldl (/) 3 []

Output: 3.0

Example 3

Input: foldl max 5 [1,2,3,4]

Output: 5

Example 4

Input: foldl max 5 [1,2,3,4,5,6,7]

Output: 7

Example 5

Input: foldl (\x y -> 2*x + y) 4 [1,2,3]

Output: 43