SequenceFold[f,{x1,…,xn},{a1,a2,…}]
gives the last element of SequenceFoldList[f,{x1,…,xn},{a1,a2,…}].
SequenceFold[f,{x1,…,xn},{a1,a2,…},k]
applies f to k arguments at each step, with the first n coming from the xi or previous results, and the last k-n coming from the ai.
SequenceFold
SequenceFold[f,{x1,…,xn},{a1,a2,…}]
gives the last element of SequenceFoldList[f,{x1,…,xn},{a1,a2,…}].
SequenceFold[f,{x1,…,xn},{a1,a2,…},k]
applies f to k arguments at each step, with the first n coming from the xi or previous results, and the last k-n coming from the ai.
Details
- In SequenceFold[f,{x1,…,xn},{a1,a2,…}], the function f is assumed to have n+1 arguments.
- SequenceFold[f,{x},{a1,a2,…}] is equivalent to Fold[f,x,{a1,a2,…}].
- SequenceFold[f,{x1,…,xn},{a1,a2,…}] is equivalent to SequenceFold[f,{x1,…,xn},{a1,a2,…},n+1].
- In SequenceFold[f,{x1,…,xn},{a1,a2,…},k], the integer k must obey k≥n.
Examples
open all close allBasic Examples (2)
Successively apply a function f to a seed sequence x,y and the elements of a list:
SequenceFold[f, {x, y}, {a, b}]Successively apply a function f of 4 arguments to a seed sequence x,y and pairs of elements in a list:
SequenceFold[f, {x, y}, {a, b, c}, 4]Scope (2)
Properties & Relations (5)
SequenceFold[f,xlist,alist] returns the last element of SequenceFoldList[f,xlist,alist]:
SequenceFold[Plus, {1, 1}, ConstantArray[0, 10]]SequenceFoldList[Plus, {1, 1}, ConstantArray[0, 10]]Starting with a seed sequence of length 1 makes SequenceFold equivalent to Fold:
SequenceFold[f, {x}, {a, b, c}]Fold[f, x, {a, b, c}]An empty seed sequence makes SequenceFold apply the function to the last element of the final list:
SequenceFold[f, {}, {a, b, c}]If f has only one argument, then SequenceFold is equivalent to Nest:
SequenceFold[f, {x}, {a, b, c, d}, 1]Nest[f, x, 5]The number of arguments of the function cannot be smaller than the length of the seed sequence:
SequenceFold[f, {x, y, z}, {a, b, c}, 2]If they are equal, then the actual elements of the list in the third argument are not used:
SequenceFold[f, {x, y, z}, {a, b, c}, 3]See Also
Related Guides
History
Text
Wolfram Research (2015), SequenceFold, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceFold.html.
CMS
Wolfram Language. 2015. "SequenceFold." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SequenceFold.html.
APA
Wolfram Language. (2015). SequenceFold. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequenceFold.html
BibTeX
@misc{reference.wolfram_2026_sequencefold, author="Wolfram Research", title="{SequenceFold}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceFold.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sequencefold, organization={Wolfram Research}, title={SequenceFold}, year={2015}, url={https://reference.wolfram.com/language/ref/SequenceFold.html}, note=[Accessed: 12-June-2026]}