NestList

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)

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

Repeatedly apply Cos to to a number:

The function to nest can be a pure function:

Scope  (4)

Nesting a function can build a formula:

Nesting can return a single number:

The nested function can operate on a list:

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

Generalizations & Extensions  (1)

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

Applications  (15)

Powers of 2:

Successive integers:

Successive squaring:

Growth of annually compounded capital:

Successive derivatives:

Newton iterations for :

Continued fraction:

Iterated map:

Iterates in the problem:

Linear congruential pseudorandom generator:

Random walk:

Iterated string replacements:

Successively append to a list:

Successively rotate a list:

Operations on a pair of values:

Properties & Relations  (5)

Nest gives the last element of NestList:

Nesting zero times simply returns to the original argument:

FixedPointList goes on until the result no longer changes:

NestWhileList goes on while a condition is true:

FoldList automatically inserts second arguments from a list:

Neat Examples  (4)

Text effects:

Power towers:

Argument doubling:

Sierpiński text:

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

CMS

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

BibTeX

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

BibLaTeX

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