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: mapAccumR
Type: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
Description: mapAccumR is similar to mapAccumL except that the list is processed from right-to-left rather than left-to-right
Related: group, groupBy, inits, intersperse, mapAccumL, nub, nubBy, partition, sort, sortBy, tails, transpose

Example 1

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

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

Example 2

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

Output: (19,[34,52,40])

Example 3

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

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

Example 4

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

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

Example 5

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

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