Skip to content

Instantly share code, notes, and snippets.

@dionyziz
Created April 21, 2020 08:09
Show Gist options
  • Save dionyziz/0d5d186a207ea08a495cf581c7cf5ed5 to your computer and use it in GitHub Desktop.
Save dionyziz/0d5d186a207ea08a495cf581c7cf5ed5 to your computer and use it in GitHub Desktop.
const y = (t) => {
const b = ({b, t}) => {
return (n) => {
const a = () => {
return {b, t}
}
return t(b(a()))(n)
}
}
const a = () => {
return {
b: ({b, t}) => {
return (n) => {
const a = () => {
return {b, t}
}
return t(b(a()))(n)
}
},
t
}
}
return t(b(a()))
}
const fact = y((self) => (n) => {
if (n == 0) {
return 1
}
return n * self(n - 1)
})
console.log(fact(5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment