[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Challenge] Smallest table copy
- From: Philipp Janda <siffiejoe@...>
- Date: Wed, 07 May 2014 17:00:38 +0200
Am 07.05.2014 15:40 schröbte Thiago L.:
So I have a challenge for you all: A table copy script in less than 270
chars
239 bytes. Stole some of your tricks. Not extensively tested but seems
to work ...
Philipp
local t,x,f=type,"table" f=function(a,d,c,r)r={}c=c or{}c[a]=r for k,v in pairs(a)do r[d and t(k)==x and(c[k]or f(k,d,c))or k]=d and t(v)==x and(c[v]or f(v,d,c))or v end return r end table.copy={deep=function(a)return f(a,1)end,shallow=f}