lua-users home
lua-l archive

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


On Fri, 17 Oct 2003, Eric Tetz wrote:

> Well, I stated the wrong reason (which I realized the second I
> clicked "submit"). You don't need 'fix' because you already have a
> local to bind the closure to: 'arg'.

No, fix and arg refer to different tables.

> This function:
>
> > function curry (f, ...)
> >   local fix = arg
> >   return function (...)
> >            return f (unpack (fix), unpack (arg))
> >          end
> > end
>
> Creates a second local referring to the same table, then passes
> passes the same argument list to 'f' twice.

No, one is for the args you want to fix (curry's arg) and one is the
arguments passed to the curried function (the anonymous function's arg).

-- 
http://www.mupsych.org/~rrt/ | impossible, a.  worth doing