lua-users home
lua-l archive

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


On Mon, Oct 7, 2013 at 5:57 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Sun, Oct 6, 2013 at 10:23 PM, Jay Glascoe <jay.glascoe@gmail.com> wrote:
>> I think normally I would do something like "map(theFunction, theList)"
>> whereas Underscore has "map(theList, theFunction)".  What's cool about that,
>> in Lua, is if your your list (table) is an object with "map" to be found
>> somewhere in it's metatable's index, you can do "myObject:map(theFunction)"
>
> Yep, I went through that as well with Penlight - so it works both
> ways: there is tablex.imap (fn,t) (where t is a array-like table) but
> the List class has a map method: ls:map(fn).

That seems a reasonable compromise. The f in front ordering is for
ease of currying. Clearly this shows the incompatibility between
functional and object, wanting the arguments the other way round...

Justin