Last active
December 27, 2015 00:31
-
-
Save irvifa/f3529cbe169b81ba4875 to your computer and use it in GitHub Desktop.
xrange-lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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