logoalt Hacker News

Trung0246today at 5:27 AM0 repliesview on HN

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