Documentation for routine
rotate assembled from the following types:
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: «c␤d␤e␤a␤b␤»
Note: Available since Rakudo 2020.06.
multi sub rotate(, Int = 1 --> Seq)multi method rotate(List: Int = 1 --> Seq)
Seq with the list elements rotated to the left when
$n is positive or to the right otherwise.
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