Skip to content

Instantly share code, notes, and snippets.

@zwh8800
Created May 22, 2017 08:41
Show Gist options
  • Save zwh8800/c111c74f68c0eea7e95d4c3fece11bf2 to your computer and use it in GitHub Desktop.
Save zwh8800/c111c74f68c0eea7e95d4c3fece11bf2 to your computer and use it in GitHub Desktop.
range in lua using coroutine
function range(n)
return coroutine.wrap(function()
for i = 1, n, 1 do
coroutine.yield(i)
end
end)
end
function main()
for i in range(10) do
print(i)
end
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment