awful.util: table.join support for non-integer keys
Signed-off-by: koniu <gkusnierz@gmail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
715f95555a
commit
b9ca6b4961
|
@ -14,7 +14,7 @@ local debug = debug
|
||||||
local print = print
|
local print = print
|
||||||
local type = type
|
local type = type
|
||||||
local rtable = table
|
local rtable = table
|
||||||
local ipairs = ipairs
|
local pairs = pairs
|
||||||
local capi =
|
local capi =
|
||||||
{
|
{
|
||||||
awesome = awesome,
|
awesome = awesome,
|
||||||
|
@ -218,14 +218,19 @@ function subsets(set)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Join all tables given as parameters.
|
--- Join all tables given as parameters.
|
||||||
-- This will iterate all tables and insert value from 1 to N.
|
-- This will iterate all tables and insert all their keys into a new table.
|
||||||
-- Non integer keys are ignored.
|
|
||||||
-- @param args A list of tables to join
|
-- @param args A list of tables to join
|
||||||
-- @return A new table containing all interger keys from the arguments.
|
-- @return A new table containing all keys from the arguments.
|
||||||
function table.join(...)
|
function table.join(...)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for i = 1, arg.n do
|
for i = 1, arg.n do
|
||||||
for k, v in ipairs(arg[i]) do rtable.insert(ret, v) end
|
for k, v in pairs(arg[i]) do
|
||||||
|
if type(k) == "number" then
|
||||||
|
rtable.insert(ret, v)
|
||||||
|
else
|
||||||
|
ret[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue