by fadmmatt · 16y ago · 0 comments
I wrote up an alternate derivation based on fixed points for my compilers students:
http://matt.might.net/articles/implementation-of-recursive-f...
It also shows how to exploit the Y combinator to get speed-ups from memoization in JavaScript.
HN has had some growing pains, but there's still something special here.
As an example of the power of this approach, this caching turns the naive, exponential implementation of Fibonacci into the optimized, linear-time version
What role does the YC play in this? Is it not simply due to memoization? Does the Y-combinator version grow the stack?
The memoizing Y combinator is the same as the Y combinator, except it doesn't re-compute inputs it's already seen.
Writing recursive functions in "Y-combinator style" is a way to expose internal recursive call sites to external inspection and manipulation.
The Y combinator version still grows the stack.