lua-users home
lua-l archive

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


2012/12/18 steve donovan <steve.j.donovan@gmail.com>:


>
> Currently I have a little thing for string lambdas, like so
>
> A{{1,10},{2,20}}:map '_[1]'  -> {1,2}
>
> or arr:sort '_1.name < _2.name'
>
> Not that I expect this will be universally adopted.  But it is no less
> valid Lua style than writing out the for loop diligently, and no less
> efficient.
>

I find any lambda notation that uses special+numeric placeholders
unreadable.  So I prefer the default argument list when `->` is omitted
to be as much as needed of `(a,b,c,...)`, not `(_1,_2,_3,...)`.

I can't make out what your first example is supposed to do.
The second one would look better to me as

    arr:sort 'a.name < b.name'

under the convention that (a,b,c,...) is the default argument list.