WOLFRAM

NestList[f,expr,n]

gives a list of the results of applying f to expr 0 through n times.

NestList[f,n]

represents an operator form of NestList that can be applied to expressions.

Details

  • NestList[f,expr,n] gives a list of length n+1.

Examples

open allclose all

Basic Examples  (3)Summary of the most common use cases

Create a list by applying f to x from 0 to 4 times:

Out[1]=1

Repeatedly apply Cos to to a number:

Out[1]=1

The function to nest can be a pure function:

Out[1]=1

Scope  (4)Survey of the scope of standard use cases

Nesting a function can build a formula:

Out[1]=1

Nesting can return a single number:

Out[1]=1

The nested function can operate on a list:

Out[1]=1

Use the operator form to create a list from different starting expressions:

Out[2]=2
Out[3]=3
Out[4]=4

Generalizations & Extensions  (1)Generalized and extended use cases

To nest a function of more than one argument, the arguments can be put into a list:

Out[1]=1

Applications  (15)Sample problems that can be solved with this function

Powers of 2:

Out[1]=1

Successive integers:

Out[1]=1

Successive squaring:

Out[1]=1

Growth of annually compounded capital:

Out[1]=1

Successive derivatives:

Out[1]=1

Newton iterations for :

Out[1]=1

Continued fraction:

Out[1]=1

Iterated map:

Out[1]=1
Out[2]=2

Iterates in the problem:

Out[1]=1

Linear congruential pseudorandom generator:

Out[1]=1

Random walk:

Out[1]=1
Out[2]=2

Iterated string replacements:

Out[1]=1

Successively append to a list:

Out[1]=1

Successively rotate a list:

Out[1]=1

Operations on a pair of values:

Out[1]=1

Properties & Relations  (5)Properties of the function, and connections to other functions

Nest gives the last element of NestList:

Out[1]=1
Out[2]=2

Nesting zero times simply returns to the original argument:

Out[1]=1

FixedPointList goes on until the result no longer changes:

Out[1]=1
Out[2]=2

NestWhileList goes on while a condition is true:

Out[1]=1

FoldList automatically inserts second arguments from a list:

Out[1]=1
Out[2]=2

Neat Examples  (4)Surprising or curious use cases

Text effects:

Out[1]=1
Out[2]=2

Power towers:

Out[1]=1
Out[2]=2

Argument doubling:

Out[1]=1
Out[2]=2

Sierpiński text:

Out[1]=1
Wolfram Research (1988), NestList, Wolfram Language function, https://reference.wolfram.com/language/ref/NestList.html (updated 2024).
Wolfram Research (1988), NestList, Wolfram Language function, https://reference.wolfram.com/language/ref/NestList.html (updated 2024).

Text

Wolfram Research (1988), NestList, Wolfram Language function, https://reference.wolfram.com/language/ref/NestList.html (updated 2024).

Wolfram Research (1988), NestList, Wolfram Language function, https://reference.wolfram.com/language/ref/NestList.html (updated 2024).

CMS

Wolfram Language. 1988. "NestList." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/NestList.html.

Wolfram Language. 1988. "NestList." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/NestList.html.

APA

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

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

BibTeX

@misc{reference.wolfram_2025_nestlist, author="Wolfram Research", title="{NestList}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/NestList.html}", note=[Accessed: 21-May-2025 ]}

@misc{reference.wolfram_2025_nestlist, author="Wolfram Research", title="{NestList}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/NestList.html}", note=[Accessed: 21-May-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_nestlist, organization={Wolfram Research}, title={NestList}, year={2024}, url={https://reference.wolfram.com/language/ref/NestList.html}, note=[Accessed: 21-May-2025 ]}

@online{reference.wolfram_2025_nestlist, organization={Wolfram Research}, title={NestList}, year={2024}, url={https://reference.wolfram.com/language/ref/NestList.html}, note=[Accessed: 21-May-2025 ]}