@@ -683,7 +683,7 @@ The functional form assumes it is working on a list of integers C<^$n>.
683
683
684
684
=item rotor
685
685
686
- multi method rotor ( *@cycle )
686
+ multi method rotor ( *@cycle, :$partial )
687
687
688
688
Takes multiple cyclical slices of the current list as specified by
689
689
C<@cycle>, which you can think of as a rotory cutter that punches out
@@ -694,12 +694,13 @@ many elements to take (the "slice") and, optionally, how many to omit
694
694
(the "gap"). The cycle repeats if C<@cycle> runs out before the list
695
695
does. The rotor stops if the list runs out first, that is, if there are
696
696
insufficient values remaining to create the entire next slice (ignoring
697
- any associated gap). The final partial slice is returned at the end,
697
+ any associated gap). If :partial is specified, the final partial slice is returned at the end,
698
698
if it is not empty. Here we slice the alphabet into alternating slices
699
699
of size 2 and 3:
700
700
701
701
my @list = 'a'...'z';
702
- @list.rotor(2,3) # <a b>,<d e f>,<g h>,<i j k>...<z>
702
+ @list.rotor(2,3) # ab, def, gh, ijk...uv, wxy
703
+ @list.rotor(2,3, :partial) # ab, def, gh, ijk...uv, wxy, z
703
704
704
705
It is allowed to specify an infinite cycle, in which case it will never
705
706
repeat, at least not internally. The supplied list may of course repeat
0 commit comments