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:

Introduced in 2015
 (10.2)