lua-users home
lua-l archive

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


> On Wed, Nov 20, 2013 at 11:04 AM, Pierre Chapuis
> <catwell@archlinux.us>wrote:
>
>> I consider defining a map() function and using it with pure functions
>> (e.g. tostring) idiomatic.
>
> I think it would be more idiomatic to have it replace the table's content
> in-place, leaving it up to the caller to copy the table or not before
> modifying it.

Right. Actually most of the time that function would work for me.
But I wouldn't know what to call it. Does it exist in other languages?

I don't think copying the table before is a good idea performance-wise,
especially on PUC Lua: https://gist.github.com/catwell/7564258

The LuaJIT version could probably be made faster by pre-allocating
the tables. I used 2.0 so I didn't have table.new handy.

-- 
Pierre Chapuis