fold

fold(f,x0,{x1,...,xn}) -- computes f(...f(f(x0,x1),x2)...)}.
fold({xn,...,x1},x0,f) -- computes f(...f(x2,f(x1,x0))...)}.
fold(f,{x0,x1,...,xn}) -- computes f(...f(f(x0,x1),x2)...)}.
fold({xn,...,x1,x0},f) -- computes f(...f(x2,f(x1,x0))...)}.

i1 : fold(toList, {a,b,c,d,e})

o1 = {{{{a, b}, c}, d}, e}

o1 : List

See also accumulate.


topindexpreviousupnext