NestWhileList
NestWhileList[f, expr, test, m, max, n]
applies f
to expr
until test
does not return True
.
It returns a list of all intermediate results. test
is a function that takes as its argument the last m
results.
max
denotes the maximum number of applications of f
and n
denotes that f
should be applied another n
times after
test
has terminated the recursion.
Attributes[NestWhileList] := {Protected}
Simple examples
In[1]:= Length[NestWhileList[Function[(Slot[1] + (3)/(Slot[1]))/(2)], 1., Function[Slot[1] =!= Slot[2]], 2]]
Out[1]= 7