lua-users home
lua-l archive

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

226! (If I am counting correctly :)

I started with Daniel's version and used loadstring and gsub to "compress" the repeated sequences...  (Didn't actually test the result :)

loadstring(('dA,t)if"table"~=type(a)thenBaCt={}r=r or{}r[a]=t Da[r[x]or d(x,r)]=r[y]or d(y,r)CBtCtable.copy={shallowA)b={}Db[x]=yCBbC,deep=d}'):gsub('%u',{A='=function(a,r',B=' return ',C=' end ',D='for x,y in next,a do '}))()

On May 8, 2014 11:25 AM, "Pierre-Yves Gérardy" <> wrote:
I doubt you can get an improvement with `load`.

    load"local a=..."

is three characters longer than


You can cache the prologue in a variable, but two functions is too
little to gain from it:

L="local a,b,c=..."load(L.."")load(L.."")

On Thu, May 8, 2014 at 4:57 PM, Philipp Janda <> wrote:
> Am 08.05.2014 15:47 schröbte Thiago L.:
>> I wonder if less than 239 chars is possible (maybe with some
>> load()/loadstring() trickery?)
> Sure. Using Paul's trick I'm currently at 230 bytes (234 if you don't like
> global `next`). But it's based on my original proposal, so you won't like it
> ...
> But using `load` is an interesting idea (e.g. for avoiding the `function`
> keyword) ...
> Philipp