27 lines
651 B
Lua
27 lines
651 B
Lua
-- Copies [key, values] from src into dest, if they do not exist
|
|
function auMergeTable(dest, src)
|
|
auForEachKV(src, function(key, value)
|
|
if (dest[key]) then return end
|
|
dest[key] = value
|
|
end)
|
|
return dest
|
|
end
|
|
|
|
function auCopyTables(...)
|
|
local dest = {}
|
|
local args = table.pack(...)
|
|
for i=1, args.n do
|
|
local tbl = args[i]
|
|
auForEachKV(tbl, function(key, value) dest[key] = value end)
|
|
end
|
|
return dest
|
|
end
|
|
|
|
-- Alternative to auConcatArrays
|
|
-- Copies src into dest
|
|
function auMergeArray(dest, src)
|
|
auForEach(src, function(value)
|
|
table.insert(dest, value)
|
|
end)
|
|
return dest
|
|
end |