Skip to content

FoldList

`FoldList[f, x, {a, b}] returns {x, f[x, a], f[f[x, a], b]}

Attributes[FoldList] := {Protected}

Simple examples

In[1]:= FoldList[f, 1, {2, 3}]
Out[1]= {1, f[1, 2], f[f[1, 2], 3]}
In[2]:= FoldList[f, {1, 2, 3}]
Out[2]= {1, f[1, 2], f[f[1, 2], 3]}
In[3]:= FoldList[f, e1, h[e2, e3, e4]]
Out[3]= h[e1, f[e1, e2], f[f[e1, e2], e3], f[f[f[e1, e2], e3], e4]]
In[4]:= FoldList[f, h, {}]
Out[4]= {h}