diff options
Diffstat (limited to 'generate.lua')
-rw-r--r-- | generate.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/generate.lua b/generate.lua new file mode 100644 index 0000000..f046356 --- /dev/null +++ b/generate.lua @@ -0,0 +1,33 @@ +local function next_number (last, current) + current = current + 1 + if current > last then + return nil + end + return current +end + + +local function range (first, last) + if first > last then + error "start of range must be less or equal to last value" + end + return next_number, last, first - 1 +end + + +local generate = { + next_number = next_number, + range = range, +} + + +function generate.trange (first, last) + local x = {} + for i in range(first, last) do + table.insert(x, i) + end + return x +end + + +return generate |