Объединение массивов

Массивы и коллекции / Массивы

local first_numbers = {2, 3, 5}
local second_numbers = {7, 11, 13}

-- No + for tables. A new array: both parts
-- are copied into an empty table
local all_numbers = {}
table.move(first_numbers, 1, #first_numbers,
           1, all_numbers)
table.move(second_numbers, 1, #second_numbers,
           #first_numbers + 1, all_numbers)
-- all_numbers = 2, 3, 5, 7, 11, 13

-- In place: the target is first_numbers,
-- the items go after its last one
table.move(second_numbers, 1, #second_numbers,
           #first_numbers + 1, first_numbers)
-- first_numbers = 2, 3, 5, 7, 11, 13

print("all_numbers = "
      .. table.concat(all_numbers, ", "))
print("first_numbers = "
      .. table.concat(first_numbers, ", "))