WolframLang: Recursion

By Xah Lee. Date: .

recursion of function with 1 arg

Nest
Recursion of a function n times.
Nest[f, x, 3] === f[f[f[x]]]
Nest
NestList
Like Nest but return a list of all steps.
NestList[f, x, 3] === {x, f[x], f[f[x]], f[f[f[x]]]}
NestList
NestWhile
Like Nest, but with a condition when to stop. NestWhile
NestWhileList
Like NestWhile but return a list of all steps. NestWhileList
FixedPoint
Recursion of a function until result no longer changes. FixedPoint
FixedPointList
Like FixedPoint but return a list of all steps. FixedPointList

recursion of function with 2 args

Fold
Similar to reduce in JavaScript and Python .
Fold[f, x, {a,b,c}] === f[f[f[x, a], b], c]
Fold
FoldList
Like Fold but return a list of all steps.
FoldList[f, x, {a,b,c}] === {x, f[x, a], f[f[x, a], b], f[f[f[x, a], b], c]}
FoldList
FoldWhile
Like Fold but with a condition test to stop. FoldWhile
FoldWhileList
Like FoldWhile but return a list of all steps.

WolframLang Loop, Iteration, Recursion

WolframLang in Depth

Basics

Comment, Print

String

Arithmetic

List

Expression, Atom, Head

Boolean

Conditional

Variable

Loop

Data Structure

Function

Pattern Matching

Advanced

Shell Tasks

Misc