I'm looking for a Lua-equivalent of this Python code (if possible):
>>> ["prefix" + suffix for suffix in ["1","2","3"] ]
['prefix1', 'prefix2', 'prefix3']
This is the Lua code that I've currently got, I'm wondering whether there's a more compact way to code this:
function foo (prefix, suffices)
local newList = {}
for k,v in pairs(suffices) do
table.insert(newList, prefix .. v)
end
return newList
end
a = foo( "prefix", {"1","2","3"} );