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
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].
Examples
open all close allBasic Examples (3)
Successively apply a function that returns a pair to a seed u and the elements of a list, returning the first element of the pair:
FoldPair[{p[#1, #2], q[#1, #2]}&, u, {1, 2, 3}]Successively apply a function that returns a pair to a seed u and the elements of a list, returning the last element of the pair:
FoldPair[{p[#1, #2], q[#1, #2]}&, u, {1, 2, 3}, Last]Provide the seed and the list of elements as a single list, having the seed as first element:
FoldPair[{p[#1, #2], q[#1, #2]}&, {a, b, c}]Scope (1)
Generalizations & Extensions (1)
Applications (2)
Find the last sublist of an arbitrary partition of a list:
FoldPair[TakeDrop, {a, b, c, d, e, f}, {1, 3, 2}]A discrete-time state-space system is represented using a state equation
and output equation
. Simulate such a system to get the final output:
FoldPair[{g[#1, #2], f[#1, #2]}&, x0, {u0, u1, u2}]Properties & Relations (2)
FoldPair returns the last element of the list returned by FoldPairList:
FoldPairList[QuotientRemainder, 498, {100, 50, 20, 5, 1}]FoldPair[QuotientRemainder, 498, {100, 50, 20, 5, 1}]FoldPair does not return by default the remainder of the process:
FoldPair[TakeDrop, {a, b, c, d, e, f}, {2, 3}]Use Last in the fourth argument to get the remainder:
FoldPair[TakeDrop, {a, b, c, d, e, f}, {2, 3}, Last]Use Identity in the fourth argument to get both:
FoldPair[TakeDrop, {a, b, c, d, e, f}, {2, 3}, Identity]Possible Issues (2)
The function in the first argument of FoldPair must return a pair of expressions:
FoldPair[MinMax[{#1, #2}]&, 10, {1, 20, 3, 25, 4, 30}]FoldPair[Min, 10, {1, 20, 3, 25, 4, 30}]FoldPairList[f,y0,{}] returns an empty list, with no last element:
FoldPairList[f, y0, {}]Therefore FoldPair[f,y0,{}] stays unevaluated:
FoldPair[f, y0, {}]Related Guides
History
Text
Wolfram Research (2015), FoldPair, Wolfram Language function, https://reference.wolfram.com/language/ref/FoldPair.html.
CMS
Wolfram Language. 2015. "FoldPair." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FoldPair.html.
APA
Wolfram Language. (2015). FoldPair. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FoldPair.html
BibTeX
@misc{reference.wolfram_2026_foldpair, author="Wolfram Research", title="{FoldPair}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/FoldPair.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_foldpair, organization={Wolfram Research}, title={FoldPair}, year={2015}, url={https://reference.wolfram.com/language/ref/FoldPair.html}, note=[Accessed: 13-June-2026]}