# FoldWhileList FoldWhileList[f,x,{a1,a2,},test]

returns {x,f[x,a1],f[f[x,a1],a2],}, repeatedly applying f with subsequent values ai until applying test to the result does not yield True.

FoldWhileList[f,list,test]

is equivalent to FoldWhileList[f,First[list],Rest[list],test].

FoldWhileList[f,x,{a1,a2,},test,m]

supplies the most recent m results as arguments for test at each step.

FoldWhileList[f,x,{a1,a2,},test,All]

supplies all results so far as arguments for test at each step.

FoldWhileList[f,x,{a1,a2,},test,m,n]

returns n additional results by applying f an extra n times after test fails.

FoldWhileList[f,x,{a1,a2,},test,m,-n]

returns n fewer results.

FoldWhileList[f,test]

represents an operator form of FoldWhileList that can be applied to expressions.

# Details # Examples

open allclose all

## Basic Examples(3)

Divide 5! by increasing positive integers, until the result is a noninteger:

Add 1/n8 terms until Unequal yields False for two consecutive results in machine arithmetic:

Divide 5! by consecutive positive integers and return the last integer result:

## Scope(8)

Starting with 12, subtract increasing integers while the remainder is still positive:

Compute a random walk starting from the origin, and return the first point whose norm is beyond 5:

Fold Cross over a list of random unit vectors while the norm of the result is larger than 0.1:

Add 1/n8 terms until Unequal yields False for two consecutive results in machine arithmetic:

Add random integers to 0 while all results are different, returning the first value that was repeated:

Divide 5! by consecutive positive integers, returning the first noninteger result:

Return the last integer result:

Return the next-to-last integer result:

Abort the computation before it is finished:

Use FoldWhileList in operator form:

## Properties & Relations(4)

If test[x] does not yield True, FoldWhileList[f,x,alist,test] returns {x}:

FoldWhile[f,x,alist,test,] is equivalent to Last[FoldWhileList[f,x,alist,test,]]:

FoldWhileList[f,x,list,True&] is equivalent to FoldList[f,x,list]:

FoldWhileList[f,x,list,test,m,n] is equivalent to NestWhileList[f,x,test,m,Length[list],n] for a function f taking only one argument: