Created
September 9, 2015 09:18
-
-
Save tst2005/17d9d6e7f02bc821b3d9 to your computer and use it in GitHub Desktop.
argument code generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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