lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday 30 January 2007 8:18 am, Thomas Hafner wrote:
> This will do it:
>
>   target = {unpack(source)}

unpack(t) only works with arrays, that is, a table with consecutive integer 
keys without holes.  (see the length operator (#) definition (ref manual, 
2.5.5))

also, i guess there's a implementation limit to returned values... was it 
about 4000 items?

a bit testing:

t={}
for i =1,1e6 do
table.insert (t, 1)
if #{unpack(t)} ~= i then print ("fail!", i) break end
if i % 10 == 0 then print (i) end
end

goes for a while, then fails with "stack overflow (table too big to unpack)", 
when t reaches 2048 elements

-- 
Javier

Attachment: pgp3XT336qHwu.pgp
Description: PGP signature