FoldPair

FoldPair[f,y0,list]

gives the last element of FoldPairList[f,y0,list].

FoldPair[f,y0,list,g]

gives the last element of FoldPairList[f,y0,list,g].

FoldPair[f,{a0,a1,a2,}]

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

Details

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

Examples

open allclose all

Basic Examples  (3)

In[1]:=
Click for copyable input
Out[1]=
In[1]:=
Click for copyable input
Out[1]=
In[1]:=
Click for copyable input
Out[1]=

Scope  (1)

Generalizations & Extensions  (1)

Applications  (2)

Properties & Relations  (2)

Possible Issues  (1)

See Also

FoldPairList  Fold  FoldList  TakeDrop  QuotientRemainder

Introduced in 2015
(10.2)