[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Random thought: short lambda syntax (no patching required!)
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 26 May 2014 11:03:17 +0200
On Mon, May 26, 2014 at 10:53 AM, Xavier Wang <weasley.wx@gmail.com> wrote:
> What about just like C++'s lambda syntax?
>
> table.sort(t, _1 > _2)
That's what I did in Penlight:
http://stevedonovan.github.io/Penlight/api/topics/07-functional.md.html#Placeholder_Expressions
Although there are limitations - you can't express and/or as operators.
PL also does 'string lambdas', but in the explicit '|x,y| x > y' form
(string lambdas are very efficient to memoize). There's also a short
form with a single argument '_', Scala-like. Just about all PL
functions can accept string lambdas:
> l = List{10,20,5,2,6}
> = l:filter '_ > 10'
{20}