On Mon, May 25, 2009 at 12:37:34PM -0700, yary wrote:
> That's an enjoyable and educational read, thanks!
>
> There's one form under TMTOWTDI that I'd like to see, but can't figure
> out myself. It's the version analogous to this perl5 snippet-
>
> sub odd {$_ % 2}
> say grep odd,0..6;
>
> -where the line that filters the list mentions no variables at all,
> and "$_" does its work behind the curtains.
How about...?
sub odd { ^$a % 2 }
say grep &odd, 0..6;
This gets us to within one character of the p5 version. I think
we also have the possibility of
subset odd where { $_ % 2 }
say grep odd, 0..6;
which is the same length as the p5 version, but afaict this
last one doesn't seem to be working in Rakudo yet.
Pm