Skip to content

Instantly share code, notes, and snippets.

@katlogic
Last active July 11, 2016 02:57
Show Gist options
  • Select an option

  • Save katlogic/7aa734f815500c05226575fd090d4c3f to your computer and use it in GitHub Desktop.

Select an option

Save katlogic/7aa734f815500c05226575fd090d4c3f to your computer and use it in GitHub Desktop.
-- print((function(f) return (function(x) return f(function(...) return x(x)(...) end) end)(function(x) return f(function(...) return x(x)(...) end) end) end)(function(f) return function(n) if n==0 then return 1 else return n*f(n-1) end end end)(10))
local function fix(f)
return (function(x)
return f(function(...)
return x(x)(...)
end)
end)(function(x)
return f(function(...)
return x(x)(...)
end)
end)
end
local function fact(self,n) if n==0 then return 1 else return n*self(n-1) end end
print(fix(function(f) return function(n) return fact(f, n) end end)(5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment