Y: Recursion The Hard Way
summary
Shows how to get recursion without named functions by building a typed Y combinator in Go that actually recurses, and adds closure-backed maps for memoized typed recursor storage so factorials cache across calls. Demonstrates stack limits (about 16,700,000 recursive calls on an Intel MacBook Pro), factorial overflow past 20 with 64-bit ints, lack of tail-call elimination, and a reusable panic/recover local exception handler pattern. Code compiles and runs but is explicitly unsafe for production.
AI-written summary · about
chapters (18)
- 0:00Introduction
- 2:08Function vs math
- 3:31Pure functions
- 5:41Local persistent state
- 8:07Introduction to recursion and stack exhaustion
- 9:31Factorials and errors
- 13:13Panic and recover
- 16:47Higher-order functions
- 21:44DSLs and anonymous funcs
- 22:05Stack-based anecdote
- 23:49Tail recursion limits
- 24:30Memoization
- 25:54Y combinator
- 31:55Typed Y in Go
- 34:08Y with local state
- 35:14Multiple stores with Y
- 36:16Resources
- 37:21Q&A








