|
|
|
|
|
by lizmat
2752 days ago
|
|
In Perl 6 this could almost look the same: for @numbers -> $number {
next unless $number > 10;
next unless $number % 2;
work($number);
}
Although personally, I wouldn't write it like that: I would probably write it as: for @numbers.grep( { $_ > 10 && $_ % 2 } ) -> $number {
work($number)
}
or use the postfix notation: work($_) for @numbers.grep( { $_ > 10 && $_ % 2 } );
If you want to spread this out over multiple CPUs and you don't care about the order in which the work is done, you only need to add the `.race` method: for @numbers.grep( { $_ > 10 && $_ % 2 } ).race -> $number {
work($number)
}
More info: https://docs.perl6.org/routine/race |
|