문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top