19 lines
529 B
Text
19 lines
529 B
Text
local function loop(start, stop, inc)
|
|
local f = "{%3d %3d %3d} -> "
|
|
io.write(string.format(f, start, stop, inc))
|
|
local count = 0
|
|
local limit = 10
|
|
local i = start
|
|
while i <= stop do
|
|
io.write(string.format("%3d ", i))
|
|
if ++count == limit then break end
|
|
i += inc
|
|
end
|
|
print()
|
|
end
|
|
|
|
local tests = {
|
|
{-2, 2, 1}, {-2, 2, 0}, {-2, 2, -1}, {-2, 2, 10}, {2, -2, 1},
|
|
{ 2, 2, 1}, { 2, 2, -1}, { 2, 2, 0}, { 0, 0, 0}
|
|
}
|
|
for tests as test do loop(test[1], test[2], test[3]) end
|