Skip to content

Instantly share code, notes, and snippets.

@therealklanni
Last active December 2, 2015 21:20
Show Gist options
  • Save therealklanni/4398f30a2f8c5188cbd7 to your computer and use it in GitHub Desktop.
Save therealklanni/4398f30a2f8c5188cbd7 to your computer and use it in GitHub Desktop.
// 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)
})
})
}
@therealklanni
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment