Recursion, iteration, and …? [closed]
https://softwareengineering.stackexchange.com/questions/286438
-
09-10-2020 - |
문제
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.
제휴하지 않습니다 softwareengineering.stackexchange