How can I split a Lua table containing few sub-tables into two tables without changing the original table.
e.g.
split tbl = {{tbl1}, {tbl2}, {tbl3}, {tbl4}}
into subtbl1 = {{tbl1}, {tbl2}}
, subtbl2 = {{tbl3}, {tbl4}}
while keep tbl
unchanged.
String has string.sub
, but don't know if table has something similar. I don't think unpack
works for my case, also table.remove
will change the original tbl
.
Adding more information for my real case:
The tbl
is filled up with sub-tables at run-time and the number of sub-tables changes. I want to keep the first 2 sub-tables for something and pass the rest of the sub-tables (in one table) to a function.
tbl
to contain just the first two sub-tables? – Frigidarium