Hasty Briefsbeta

Bilingual

No Let, No Rec, No Problem: A Gentler Introduction to the Y and Z Combinators

4 days ago
  • #combinators
  • #functional programming
  • #recursion
  • Exploring methods to implement factorial in JavaScript without loops, recursion, or declarations.
  • Introducing a generator function to avoid direct recursion by passing a reference to itself.
  • Using the pattern g(g, ...) to emulate recursion through self-application.
  • Developing the Y combinator as a fixed-point combinator, but noting issues with eager evaluation.
  • Introducing the Z combinator with delayed evaluation to handle eager evaluation and make recursion work.
  • Showing a final solution using the Z combinator as an anonymous function without declarations.