Skip to content

Instantly share code, notes, and snippets.

@th507
Last active August 14, 2023 07:57
Show Gist options
  • Save th507/9298e318b94171ad14754c6cb4b6983a to your computer and use it in GitHub Desktop.
Save th507/9298e318b94171ad14754c6cb4b6983a to your computer and use it in GitHub Desktop.
3 different form of fixed point combinators
// Y is the fixed point combinator. w1, w2, w3 are its building block.
// one level deep
var w1 = f => n => f( w1(f) )(n)
var Y = w1
// two level deep
var w2 = g => f => n => f( g(g)(f) )(n)
var Y = w2(w2)
// three level
var w3 = g => h => f => n => f( g(h)(g)(f) )(n) // g, h can be in arbitrary order
var Y = w3(w3)(w3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment