Skip to content

Instantly share code, notes, and snippets.

@irvifa
Last active December 27, 2015 00:31
Show Gist options
  • Save irvifa/f3529cbe169b81ba4875 to your computer and use it in GitHub Desktop.
Save irvifa/f3529cbe169b81ba4875 to your computer and use it in GitHub Desktop.
xrange-lua
function xrange(from, to, step)
step = step or 1
return function(_, last)
local next = last + step
if step > 0 and next < to or step < 0 and next > to or step == 0 then
return next
end
end, nil, from - step
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment