Front page | perl.perl6.language |
Postings from October 2001
Re: reduce via ^
Thread Previous
|
Thread Next
From:
Damian Conway
Date:
October 10, 2001 04:42
Subject:
Re: reduce via ^
Message ID:
200110101142.VAA07353@indy05.csse.monash.edu.au
John observed:
> I just read Apocalypse and Exegesis 3, and something stuck out at me
> because of its omission, namely using hyper operators for reduction.
>
> $a ^+= @list; # should sum the elements of @list
>
> Larry says @a ^+ 1 will replicate the scalar value for all a's, and
> Damian talks about doing summation with the reduce function without
> mentioning this compact syntax.
>
> So am I overlooking some obvious reason why this won't work?
No. I expect that this would indeed work.
Note that it's not really a replacement for C<reduce> since it *requires*
the lvalue in order to work. But it is a nice idiom.
Why didn't we mention it in A3/E3.
Well, I suspect Larry didn't mention it because he didn't want to scare
people *too* much. I didn't mention it for a much simpler reason:
because, in the heat of trying to weld together a concise example to
explain of everything Larry had designed, this neat corollary of ^
simply didn't occur to me. ;-)
Damian
Thread Previous
|
Thread Next
-
reduce via ^
by John Williams
-
Re: reduce via ^
by Damian Conway