lua-users home
lua-l archive

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


Your original submission can be shortened by making deep copy deal with the 'is this a table' question on its input and using it always:

local k,o,n,s,d=pairs,type,"table"s,d=function(a,b)b={}for x,y in k(a)do b[x]=y end return b end,function(a,r,t)if n~=o(a)then return a end t={}r=r or{}r[a]=t for x,y in k(a)do x=r[x]or d(x,r)y=r[y]or d(y,r)t[x]=y end return t end table.copy={shallow=s,deep=d}

Daniel.