[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Using unpack() twice in a single function call
- From: "Aaron Brown" <arundelo@...>
- Date: Fri, 4 Aug 2006 13:42:44 -0400
Hugo wrote:
F(unpack(a), unpack(b))
Is there any way to use more than one unpack() in a single
function call?
As Andreas pointed out, everything but the last expression
gets adjusted to one value.
You might find something like this useful:
-- Like unpack, but accepts multiple arguments:
function multunpack(...)
local ret = {}
for i = 1, select("#", ...) do
for _, rec in ipairs(select(i, ...)) do
ret[#ret + 1] = rec
end -- _, rec
end -- i
return unpack(ret)
end -- multunpack
print(multunpack({23, 45}, {-1, -2}))
23 45 -1 -2
--
Aaron