Show HN: Combinators in Array Languages
2 days ago
- The Y combinator (Sage bird) provides fixed-point recursion without named functions, but in eager languages like sw-MLPL it diverges unless delayed.
- The applicative Sage (Z combinator) fixes this by wrapping self-application in a named partial function, enabling recursion over strict evaluation.
- The table of birds (Identity, Kestrel, Thrush, Mockingbird, Bluebird, Cardinal, Warbler, Starling, Sage) shows each combinator's λ-term, behavior, and sw-MLPL definition.
- sw-MLPL stays eager intentionally; APL-like languages (Dyalog, BQN, J) provide built-in self-reference (⍺, 𝕊, ^:_) making fixed-point combinators unnecessary for practical recursion.
- Practical implementation: define a builder function receiving recursion as argument (e.g., fact_body), use `applicative_sage` to tie the knot, and call the result for correct recursion without names.
- The Sage bird is implemented as `call(:u:bluebird, :u:mockingbird, :u:lark)` but never forced in sw-MLPL; the eager-safe version uses `z_step` and `z_recur` for actual fixed-point computation.
- Four resources provide runnable code: demo-combinators (source, lessons, docs) and the APL2-idioms plane file with u:fix.