Functions Index :: A :: ArrayRotate
Module:
array :: transforms
Definition:
ArrayRotate(string array, int num_indexes)
Description:
Rotates the indexes of the elements of array (ie it shifts all elements either left or right and puts the overflowed elements' block at the opposite side of the array). Returns the resulting array.
Arguments:
array: The array to rotate.
num_indexes: The number of indexes (ie positions) to rotate array elements.
If > 0 the rotation is made towards the end of the array (the elements are right-shifted and the last block is moved to array's start). If < 0 the rotation is made towards the start of the array (the elements are left-shifted and the first block is moved to array's end).
Notes and conditions on arguments relations:
1] If num_indexes > array.ArrayLen() the modulo of the division with array.ArrayLen() is used.
Examples:
a1 = "1,2,3,4,5,6,7,8,9,10"
a2 = a1.ArrayRotate(4) # a2 == "7,8,9,10,1,2,3,4,5,6"
a3 = a1.ArrayRotate(-4) # a3 == "5,6,7,8,9,10,1,2,3,4"
a4 = a1.ArrayRotate(12) # a4 == "9,10,1,2,3,4,5,6,7,8"