awful.util.table.concat: take any number of arguments

Allows joining more than 2 tables at a time

Signed-off-by: koniu <gkusnierz@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
koniu 2009-04-15 20:29:00 +01:00 committed by Julien Danjou
parent efc3cc4c15
commit 8cbb65d5c2
1 changed files with 6 additions and 10 deletions

View File

@ -218,18 +218,14 @@ function subsets(set)
end
--- Concat all tables given as parameters.
-- This will iterate both tables and insert value from 1 to N.
-- This will iterate all tables and insert value from 1 to N.
-- Non integer keys are ignored.
-- @param t1 First table.
-- @param t2 Second table.
-- @return A new table with t1 and t2 concatened.
function table.concat(t1, t2)
-- @param args A list of tables to concatenate
-- @return A new table with arguments concatened.
function table.concat(...)
local ret = {}
for k, v in ipairs(t1) do
ret[#ret + 1] = v
end
for k, v in ipairs(t2) do
ret[#ret + 1] = v
for i = 1, arg.n do
for k, v in ipairs(arg[i]) do table.insert(ret, v) end
end
return ret
end