82.367
Bearbeitungen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 115: | Zeile 115: | ||
-- Removes all spaces at the start and at the end of a string | -- Removes all spaces at the start and at the end of a string | ||
return s:match("^%s*(.-)%s*$") | return s:match("^%s*(.-)%s*$") | ||
end | |||
function merge_arrays(t1, t2) | |||
-- merge tables that are arrays: {1,2,3} and {3,4,5} | |||
local result = {} | |||
for i = 1, #t1 do | |||
table.insert(result, t1[i]) | |||
end | |||
for i = 1, #t2 do | |||
table.insert(result, t2[i]) | |||
end | |||
return result | |||
end | |||
function merge_tables(t1, t2) | |||
-- merge tables that are key-value: {a=1, b=2} and {c=3, d=4} | |||
result={} | |||
for k, v in pairs(t1) do | |||
result[k] = v | |||
end | |||
for k, v in pairs(t2) do | |||
result[k] = v | |||
end | |||
return result | |||
end | end | ||