[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Challenge] Smallest table copy
- From: Scott Morgan <blumf@...>
- Date: Wed, 07 May 2014 15:34:43 +0100
On 07/05/14 14:40, Thiago L. wrote:
> So I have a challenge for you all: A table copy script in less than 270
> chars
...
> Finally, here is the 270 chars long script made: [1]
> 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)t={}r=r or{}r[a]=t for x,y in
> k(a)do if n==o(x)then x=r[x]or d(x,r)end if n==o(y)then y=r[y]or
> d(y,r)end t[x]=y end return t end table.copy={shallow=s,deep=d}
>
> [1] - This one might be a bit easier to read/understand:
> https://gist.github.com/SoniEx2/fc5d3614614e4e3fe131
Would it not be better to compare luac output than source size?
Also, run times?
Scott