Skip to content

NestList

NestList[f, expr, n] returns f wrapped around expr first once, then twice, and so on up to n times.

Attributes[NestList] := {Protected}

Simple examples

In[1]:= NestList[f, x, 3]
Out[1]= {x, f[x], f[f[x]], f[f[f[x]]]}
In[2]:= NestList[Function[Slot[1]^2], {1, 2, 3}, 3]
Out[2]= {{1, 2, 3}, {1, 4, 9}, {1, 16, 81}, {1, 256, 6561}}