3 ms·
I must confess, I have never been clear on the difference between iteration and recursion, or more specifically what differentiates a tail recursive loop from a
by noelwelsh 2y ago
I must confess, I have never been clear on the difference between iteration and recursion, or more specifically what differentiates a tail recursive loop from an iteration. Usage of iteration in the context of, say, an iterative solution technique such as gradient descent or an iterated function system feels very much like a (tail) recursion.
- eddd-ddde 2y agoRecursion without optimizations requires a possibly unbounded stack. Tail call optimization allows optimizing certain recursive functions in a way that no nested stack frames are needed. So from a purely functional point of view, tail recursion and iteration are essentially a bijection.