SequenceFoldList[f,{x1,…,xn},{a1,a2,…}]
gives {x1,…,xn,f[x1,…,xn,a1],f[x2,…,xn,f[x1,…,xn,a1],a2],…}.
SequenceFoldList[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.
SequenceFoldList
SequenceFoldList[f,{x1,…,xn},{a1,a2,…}]
gives {x1,…,xn,f[x1,…,xn,a1],f[x2,…,xn,f[x1,…,xn,a1],a2],…}.
SequenceFoldList[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 SequenceFoldList[f,{x1,…,xn},{a1,a2,…}], the function f is assumed to take n+1 arguments.
- If xlist and alist are lists of length n and m respectively, then SequenceFoldList[f,xlist,alist] returns a list of length n+m. Any or both of n and m can be zero.
- SequenceFoldList[f,{x},{a,b,…}] is equivalent to FoldList[f,x,{a,b,…}].
- SequenceFoldList[f,{x1,…,xn},{a1,a2,…}] is equivalent to SequenceFoldList[f,{x1,…,xn},{a1,a2,…},n+1].
- If xlist and alist are lists of length n and m respectively, then SequenceFoldList[f,xlist,alist,k] returns a list of length Max[2n+m-k+1,n]. Any of n, m, k can be zero, as long as 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:
SequenceFoldList[f, {x, y}, {a, b, c}]Successively apply a function f of 4 arguments to a seed sequence x,y and pairs of elements in a list:
SequenceFoldList[f, {x, y}, {a, b, c}, 4]Scope (2)
Applications (2)
SequenceFoldList[Plus, {1, 1}, ConstantArray[0, 10]]Fibonacci /@ Range[12]Show convergence to the exact solution when increasing the order of extrapolation:
h = 0.1;
t = Range[0, 10, h];
f = Cos[t];ListPlot[SequenceFoldList[#1 + h#2&, {0}, Drop[f, 1]] - Sin[t]]ListPlot[SequenceFoldList[-#1 / 3 + 4 / 3#2 + 2h / 3#3&, Sin[{0, h}], Drop[f, 2]] - Sin[t]]ListPlot[SequenceFoldList[2#1 / 11 - 9#2 / 11 + 18#3 / 11 + 6h / 11#4&, Sin[{0, h, 2h}], Drop[f, 3]] - Sin[t]]ListPlot[SequenceFoldList[-3#1 / 25 + 16#2 / 25 - 36#3 / 25 + 48#4 / 25 + 12h / 25#5&, Sin[{0, h, 2h, 3h}], Drop[f, 4]] - Sin[t]]Properties & Relations (10)
SequenceFold[f,xlist,alist] returns the last element of SequenceFoldList[f,xlist,alist]:
SequenceFoldList[f, {x, y}, {a, b, c}]SequenceFold[f, {x, y}, {a, b, c}]Last[%%] === %Each element of the result of SequenceFoldList[f,xlist,alist] is constructed from the previous one and an element of alist:
list = SequenceFoldList[f, {x, y}, {a, b, c, d}]list[[3]] === f[list[[1]], list[[2]], a]list[[4]] === f[list[[2]], list[[3]], b]list[[5]] === f[list[[3]], list[[4]], c]list[[6]] === f[list[[4]], list[[5]], d]Each element of the result of SequenceFoldList[f,xlist,alist,k] is constructed from the previous one and several elements of alist:
list = SequenceFoldList[f, {x, y}, {a, b, c, d, e, f}, 5]list[[3]] === f[list[[1]], list[[2]], a, b, c]list[[4]] === f[list[[2]], list[[3]], b, c, d]list[[5]] === f[list[[3]], list[[4]], c, d, e]list[[6]] === f[list[[4]], list[[5]], d, e, f]SequenceFold gives the last element of the result of SequenceFoldList:
SequenceFoldList[f, {x, y}, {a, b, c}]Last[%]SequenceFold[f, {x, y}, {a, b, c}]Starting with a seed sequence of length 1 makes SequenceFoldList equivalent to FoldList:
SequenceFoldList[f, {x}, {a, b, c}]FoldList[f, x, {a, b, c}]An empty seed sequence makes SequenceFoldList equivalent to Map:
SequenceFoldList[f, {}, {a, b, c}]If the list in the third argument is empty, then the seed sequence is returned:
SequenceFoldList[f, {x, y}, {}]SequenceFoldList[f, {}, {}]SequenceFoldList[f, {}, {}, 7]This is equivalent to applying f to a partitioned list:
SequenceFoldList[f, {}, {a, b, c, d, e}, 2]f@@@Partition[{a, b, c, d, e}, 2, 1]If f has only one argument, then SequenceFoldList is equivalent to NestList:
SequenceFoldList[f, {x}, {a, b, c, d}, 1]NestList[f, x, 5]The number of arguments of the function cannot be smaller than the length of the seed sequence:
SequenceFoldList[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:
SequenceFoldList[f, {x, y, z}, {a, b, c}, 3]See Also
Related Guides
History
Text
Wolfram Research (2015), SequenceFoldList, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceFoldList.html.
CMS
Wolfram Language. 2015. "SequenceFoldList." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SequenceFoldList.html.
APA
Wolfram Language. (2015). SequenceFoldList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequenceFoldList.html
BibTeX
@misc{reference.wolfram_2026_sequencefoldlist, author="Wolfram Research", title="{SequenceFoldList}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceFoldList.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sequencefoldlist, organization={Wolfram Research}, title={SequenceFoldList}, year={2015}, url={https://reference.wolfram.com/language/ref/SequenceFoldList.html}, note=[Accessed: 13-June-2026]}