# FoldPairList

FoldPairList[f,y0,{a1,a2,}]

gives the list of successive xi obtained by applying f to pairs of the form {yi-1,ai}, where at each step f returns {xi,yi}.

FoldPairList[f,y0,list,g]

gives the list of successive values of g[{xi,yi}].

FoldPairList[f,{a0,a1,a2,}]

is equivalent to FoldPairList[f,a0,{a1,a2,}].

# Examples

open allclose all

## Basic Examples(7)

Partition a list into sublists of different lengths:

Break an amount of money into bills of given values:

Return both the quotients and the remainders at each step:

## Scope(2)

Use a list in the third argument:

Use an arbitrary head in the third argument:

By default, FoldPairList returns only the first elements of the pairs:

Use FoldPairList with fourth argument Last to get the second element of the successive pairs:

## Generalizations & Extensions(1)

Use Throw to exit a FoldPairList:

## Applications(2)

For each element of a list, return True if it is larger than all previous ones, and False otherwise:

A discrete-time state-space system is represented using a state equation and output equation . Simulate such a system to get the outputs :

## Properties & Relations(2)

Return the seed and all but the last elements of the third argument:

Return the list in the third argument:

FoldPairList returns one element less than FoldList:

## Possible Issues(2)

The function in the first argument of FoldPairList must return a pair of expressions:

FoldPairList[f,y0,{}] returns an empty list, with no last element:

Therefore FoldPair[f,y0,{}] stays unevaluated:

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

#### Text

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

#### CMS

Wolfram Language. 2015. "FoldPairList." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FoldPairList.html.

#### APA

Wolfram Language. (2015). FoldPairList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FoldPairList.html

#### BibTeX

@misc{reference.wolfram_2024_foldpairlist, author="Wolfram Research", title="{FoldPairList}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/FoldPairList.html}", note=[Accessed: 15-August-2024 ]}

#### BibLaTeX

@online{reference.wolfram_2024_foldpairlist, organization={Wolfram Research}, title={FoldPairList}, year={2015}, url={https://reference.wolfram.com/language/ref/FoldPairList.html}, note=[Accessed: 15-August-2024 ]}