In List§
See primary documentation in context for routine rotate
multi rotate(, Int = 1 --> Seq)multi method rotate(List: Int = 1 --> Seq)
Returns a Seq
with the list elements rotated to the left when $n
is positive or to the right otherwise.
Examples:
say <a b c d e>.rotate(2); # OUTPUT: (c d e a b)say <a b c d e>.rotate(-1); # OUTPUT: (e a b c d)
Note: Before Rakudo version 2020.06 a new List
was returned instead of a Seq
.
In Supply§
See primary documentation in context for method rotate
method rotate(Supply: = 1)
Creates a supply with elements rotated to the left when $rotate
is positive or to the right otherwise, in which case the invocant is tapped on before a new supply is returned.
my = Supply.from-list(<a b c d e>).rotate(2);.tap(); # OUTPUT: «cdeab»
Note: Available since Rakudo 2020.06.