Pregunta

Here are three common code structures that apply a function multiple times:

foo(x) {
    if basecase(x) return k else return foo(g(x))
}

uses recursion.

for i in 0..10 {
    n *= bar(i)
}

uses iteration.

baz(baz(baz(baz(quux))))

uses...?

In mathematics it'd be considered iteration, but mathematics doesn't generally concern itself with for and while loops, which are what people associate with the term in programming. How do programmers tersely and unambiguously refer to the third construct?

¿Fue útil?

Solución

The term you're looking is for is function composition, although I'm not sure if there's a more specific term for the special case of a function composed with itself.

Licenciado bajo: CC-BY-SA con atribución
scroll top