Better lambdas!!!!!!!!!!
Meta via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 10 13:12:34 PDT 2015
On Thursday, 10 September 2015 at 20:10:49 UTC, Meta wrote:
> On Thursday, 10 September 2015 at 19:37:53 UTC, Ola Fosheim
> Grøstad wrote:
>> How about just having numbered parameters like this:
>>
>> { $2 < ($1*$2) }
>
> What about this situation?
>
> [[1, 2], [3, 4], [5, 6]].reduce!{
> auto localMax = { $1 > $2 ? $1 : $2; }
> auto first = $1.reduce!localMax;
> auto second = $2.reduce!localMax;
>
> return first > second ? first : second;
> }
>
> How can the compiler tell which $1 and $2 is which? What if one
> wants to access both the outer $1 and the inner $1 in localMax?
Should be `return first > second ? $1 : $2`, but you get the idea.
More information about the Digitalmars-d
mailing list