Skip to content

Instantly share code, notes, and snippets.

@tst2005
Created September 9, 2015 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tst2005/17d9d6e7f02bc821b3d9 to your computer and use it in GitHub Desktop.
Save tst2005/17d9d6e7f02bc821b3d9 to your computer and use it in GitHub Desktop.
argument code generator
local function t1(n)
local t = {}
for i = 1, n do
t[i] = "a" .. i
end
return table.concat(t, ',')
end
local function t2(n)
local a = n>0 and "a1" or ""
for i = 2, n do
a = a..",a" .. i
end
return a
end
for n = -1,10 do
print(n)
assert(t1(n) == t2(n))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment