Skip to content

Comment on The Yin and Yang of Programming

Comments

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.

Recursion 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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.