Skip to content

Commit

Permalink
Document sub rotor
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Mar 9, 2023
1 parent 7f9b27d commit d0ac898
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion doc/Type/List.rakudoc
Expand Up @@ -1172,7 +1172,7 @@ L<Range|/type/Range> constructed with C<0..^$from>:
# (2 0 1)
# (2 1 0)

=head2 method rotor
=head2 routine rotor

method rotor(*@cycle, Bool() :$partial --> Seq:D)

Expand Down Expand Up @@ -1207,6 +1207,19 @@ Combining multiple cycles and C<:partial> also works:

See L<this blog post for more elaboration on rotor|http://blogs.perl.org/users/zoffix_znet/2016/01/perl-6-rotor-the-king-of-list-manipulation.html>.

multi sub rotor(Int:D $batch, \source, Bool() :$partial --> Seq:D)
multi sub rotor(*@cycle, \source, Bool() :$partial --> Seq:D)

Available as of 6.e language version (early implementation exists in Rakudo
compiler 2022.02+).

say rotor(3, 'a'..'h').join('|'); # OUTPUT: «a b c|d e f␤»
say rotor(3, 'a'..'h', :partial).join('|'); # OUTPUT: «a b c|d e f|g h␤»
say rotor(2 => 1, 'a'..'h').join('|'); # OUTPUT: «a b|d e|g h␤»
say rotor(3 => -1, 'a'..'h').join('|'); # OUTPUT: «a b c|c d e|e f g␤»
say rotor(1 => 1, 3 => -1, 'a'..'h', :partial).join('|');
# OUTPUT: «a|c d e|e|g h␤»

=head2 method batch

multi method batch(Int:D $batch --> Seq)
Expand Down

0 comments on commit d0ac898

Please sign in to comment.