[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Challenge] Smallest table copy
- From: Daniel Stephens <daniel@...>
- Date: Wed, 07 May 2014 10:46:55 -0700
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.