Perl 6 Cool Perl 6 #18

Iterating n values at a time

The block can also have multiple parameters

This causes the loop to iterate n-at-a-time

for 1..12 -> $a, $b { say "$a, $b"; }

1, 2
3, 4
5, 6
7, 8
9, 10
11, 12

for 1..12 -> $a, $b, $c, $d { say "$a, $b, $c, $d"; }

1, 2, 3, 4
5, 6, 7, 8
9, 10, 11, 12
Copyright © 2010
http://www.pmichaud.com/2010/pres/