Skip to content

Commit 23147dd

Browse files
committed
':partial' option for partial final rotor result
1 parent 84b405c commit 23147dd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

S32-setting-library/Containers.pod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ The functional form assumes it is working on a list of integers C<^$n>.
683683

684684
=item rotor
685685

686-
multi method rotor ( *@cycle )
686+
multi method rotor ( *@cycle, :$partial )
687687

688688
Takes multiple cyclical slices of the current list as specified by
689689
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
694694
(the "gap"). The cycle repeats if C<@cycle> runs out before the list
695695
does. The rotor stops if the list runs out first, that is, if there are
696696
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,
698698
if it is not empty. Here we slice the alphabet into alternating slices
699699
of size 2 and 3:
700700

701701
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
703704

704705
It is allowed to specify an infinite cycle, in which case it will never
705706
repeat, at least not internally. The supplied list may of course repeat

0 commit comments

Comments
 (0)