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

Module: List
Function: mapAccumL
Type: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
Description: mapAccumL f s l applies f to an accumulating "state" parameter s and to each element of l in turn
Related: group, groupBy, inits, intersperse, mapAccumR, nub, nubBy, partition, sort, sortBy, tails, transpose

Example 1

Input: mapAccumL (\x y -> (x,x*y)) 5 [9,6,3]

Output: (5,[45,30,15])

Example 2

Input: mapAccumL (\x y -> (x+y,x*y)) 5 [2,4,8]

Output: (19,[10,28,88])

Example 3

Input: mapAccumL (\x y -> (x+y,y)) 5 [2,4,8]

Output: (19,[2,4,8])

Example 4

Input: mapAccumL (\x y -> (y,y)) 5 [2,4,8]

Output: (8,[2,4,8])

Example 5

Input: mapAccumL (\x y -> (x,x)) 5 [2,4,8]

Output: (5,[5,5,5])