blob: f0463562ce0c55b9e9213190f730b37e46db4f87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
|