logoalt Hacker News

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

52 pointsby sayyadirfanalilast Tuesday at 6:12 PM9 commentsview on HN

Comments

Trung0246today at 5:27 AM

Here's a funny Z combinator in typescript in pure SKI form for lambda calculus purist:

    const K = <A, B>(a: A) => (_b: B) => a;

    const S = <A, B, C>(a: (x: C) => (y: B) => A) => (b: (x: C) => B) => (c: C) => a(c)(b(c));

    const Z = S(K(S(S(K)(K))(S(K)(K))))(S(S(K(S))(K))(K(S(K(S(S)(S(K))))(S(S(K(S))(K))(K)))));
https://en.wikipedia.org/wiki/Fixed-point_combinator
p4bl0today at 5:58 AM

I feel like introducing lambda calculus (using JS syntax) would be less cumbersome and convoluted than referring to "the challenge" without really justifying it and deferring to respect the rules for so long. But maybe some people entirely unfamiliar with these concepts find this approach easier?

show 2 replies
satvikpendemtoday at 5:33 AM

Good to see this in the second chance pool. Unfortunately I don't think most commenters know what the article is about and thus we may end up with this submission leaving the front page quickly, a shame though as the YC namesake is from similar articles as these, a company that produces other companies, as Paul Graham had said.