lua-users home
lua-l archive

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


Javier Guerra wrote:
> On Thursday 11 January 2007 6:39 pm, Jerome Vuarand wrote:
> > -- Non-recursive with arrays
> > function curry(f, ...)
> > 	local cargs = {...}
> > 	return function(...)
> > 		local args = {}
> > 		for _,v in ipairs(cargs) do args[#args+1] = v end
> > 		for _,v in ipairs({...}) do args[#args+1] = v end
> > 		return f(unpack(args))
> > 	end
> > end
> 
> i think a worthwhile feature for the next Lua (5.2?) would be 
> to make unpack() accept several arrays and return the list of 
> the concatenation of all.  of course, if there's more than 
> one array, there shouldn't be any i,j parameters (who uses 
> those, anyway?).

I tried a version with a proxy table referencing the two argument list
arrays, but unpack doesn't seem to call metamethods. It could be a nice
addition to have an alternative base library which is slower but use
metamethods. Also I second your proposed unpack with multiple arrays
(unpackm for unpack multiple ?).