On Wed, May 20, 2009 at 07:55:55PM -0500, John M. Dlugosz wrote:
> If you would be so kind, please take a look at
> <http://www.dlugosz.com/Perl6/web/med-loop.html>. I spent a couple days
> on this, and besides needing it checked for correctness, found a few
> issues as well as more food for thought.
It's been legal (for more than two years) to nest a condtional inside
a loop modifier without extra parens:
@array = ($_ if .prime for 1..10);
In fact, the first example in S04 "Loop statements" is:
@evens = ($_ * 2 if .odd for 0..100);
And since the "when" modifier counts as a conditional, you can rewrite
grep Dog, @mammals
as
$_ when Dog for @mammals;
So perhaps will see a lot of subtypes used this way:
subset Odd if Int where { $_ % 2 };
@evens = ($_ * 2 when Odd for 0..*);
Well, those examples are pretty silly. Anyone with better
examples should feel free to edit the specs.
Larry