Skip to content

Instantly share code, notes, and snippets.

@usysrc
Last active November 24, 2015 16:56
Show Gist options
  • Save usysrc/a3e2b6a414e4eb86f812 to your computer and use it in GitHub Desktop.
Save usysrc/a3e2b6a414e4eb86f812 to your computer and use it in GitHub Desktop.
-- recursion in lua
-- global
rec = function(i)
rec(i+1)
end
-- forward definition
local func
func = function(i)
func(i+1)
end
-- call function
local call = function(f)
f(f)
end
local i = 0
call(function(this)
print("1")
i = i + 1
if i < 3 then
this(this)
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment