NestWhile
NestWhile(f, expr, test)
applies a function
f
repeatedly on an expressionexpr
, until applyingtest
on the result no longer yieldsTrue
.
NestWhile(f, expr, test, m)
supplies the last
m
results totest
(default value:1
).
NestWhile(f, expr, test, All)
supplies all results gained so far to
test
.
Examples
Divide by 2 until the result is no longer an integer:
>> NestWhile(#/2&, 10000, IntegerQ)625/2
Related terms
FixedPoint, FixedPointList, Nest
Implementation status
- ✅ - full supported