rotate
ErrorsCollection

rotate

Synthesised documentation from type/Supply type/List

From type/Supply

See Original text in context

method rotate(Supply:D: $rotate = 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 = Supply.from-list(<a b c d e>).rotate(2);
$supply.tap(&say); # OUTPUT: «c␤d␤e␤a␤b␤»

Note: Available since Rakudo 2020.06.

From type/List

See Original text in context

multi sub    rotate(@list,  Int:D $n = 1 --> Seq:D)
multi method rotate(List:D: Int:D $n = 1 --> Seq:D)

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.