in reply to How do I loop through a list two or more elements at a time?
In perl6 you'd just use the built-in facilities of your ordinary for loop:
for @array -> $a, $b { ... } for @array -> $one, $two, $three { ... }
Due to some regularization of the language, for loops are aware of the arity of the code block, and pulls off as many elements as needed. This also works for map as well:
my @bytwo = map -> $a, $b { [$a,$b] } @array;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Answer: How do I loop through a list two or more elements at a time?
by Anonymous Monk on Feb 05, 2006 at 04:46 UTC |
In Section
Seekers of Perl Wisdom