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 kn.

Examples

open allclose all

Basic Examples  (2)

Scope  (2)

Take one element from the list in the third argument in each iteration:

Take several elements from the list in the third argument in each iteration:

Properties & Relations  (5)

SequenceFold[f,xlist,alist] returns the last element of SequenceFoldList[f,xlist,alist]:

Starting with a seed sequence of length 1 makes SequenceFold equivalent to Fold:

An empty seed sequence makes SequenceFold apply the function to the last element of the final list:

If f has only one argument, then SequenceFold is equivalent to Nest:

The number of arguments of the function cannot be smaller than the length of the seed sequence:

If they are equal, then the actual elements of the list in the third argument are not used:

Possible Issues  (1)

This case is not well defined, and hence it is left unevaluated:

Wolfram Research (2015), SequenceFold, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceFold.html.

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_2024_sequencefold, author="Wolfram Research", title="{SequenceFold}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceFold.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_sequencefold, organization={Wolfram Research}, title={SequenceFold}, year={2015}, url={https://reference.wolfram.com/language/ref/SequenceFold.html}, note=[Accessed: 22-December-2024 ]}