Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function range(a, b, step)
- if not b then
- b = a
- a = 1
- end
- step = step or 1
- local f =
- step > 0 and
- function(_, lastvalue)
- local nextvalue = lastvalue + step
- if nextvalue <= b then return nextvalue end
- end or
- step < 0 and
- function(_, lastvalue)
- local nextvalue = lastvalue + step
- if nextvalue >= b then return nextvalue end
- end or
- function(_, lastvalue) return lastvalue end
- return f, nil, a - step
- end
Add Comment
Please, Sign In to add comment