Last active
December 2, 2015 21:20
-
-
Save therealklanni/4398f30a2f8c5188cbd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original | |
const Y = f => (x => f(v => x(x)(v)))(x => f(v => x(x)(v))) | |
// expanded as | |
const Y = f => { | |
// return the result of this IIFE | |
// f produces the fixed point function | |
return (x => { | |
// outer: | |
f(v => { | |
// invoke inner x with x as arg, | |
// returns fixed point which takes v | |
// f is invoked only once on this side | |
return x(x)(v) | |
}) | |
})(x => { | |
// inner: | |
f(v => { | |
// invoke inner x with x as arg, | |
// returns fixed point which takes v | |
// this f is invoked every subsequent time | |
return x(x)(v) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refer to The Mysterious Y-combinator