Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.
BUILT-IN WOLFRAM LANGUAGE SYMBOL

FoldPairList

FoldPairList[f,y0,{a1,a2,}]
gives the list of successive xi obtained by applying f to pairs of the form {yi-1,ai}, where at each step f returns {xi,yi}.

FoldPairList[f,y0,list,g]
gives the list of successive values of g[{xi,yi}].

FoldPairList[f,{a0,a1,a2,}]
is equivalent to FoldPairList[f,a0,{a1,a2,}].

DetailsDetails

• The function f in FoldPairList[f,y0,list] always takes two arguments and is expected to return a pair {x,y} of expressions.
• The expression expr in FoldPairList[f,y0,expr] can be any nonatomic expression, with any head.
• FoldPairList[f,y0,list] is equivalent to FoldPairList[f,y0,list,First].
• FoldPairList[f,y0,{a1,,an}] returns a list of length n.
• You can use Throw to exit from FoldPairList before it is finished.

ExamplesExamplesopen allclose all

Basic Examples  (7)Basic Examples  (7)

 In[1]:=
 Out[1]=
 In[1]:=
 Out[1]=
 In[1]:=
 Out[1]=
 In[1]:=
 Out[1]=

Partition a list into sublists of different lengths:

 In[1]:=
 Out[1]=

Break an amount of money into bills of given values:

 In[1]:=
 Out[1]=

Return both the quotients and the remainders at each step:

 In[1]:=
 Out[1]=