arrayRotate(array array, integer positions) → array rotated
arrayRotate([1, 2, 3, 4], 1) // [4, 1, 2, 3]
arrayRotate([1, 2, 3, 4], -1) // [2, 3, 4, 1]This function is available from LeekScript 4 onward. Returns a new array with the elements of array shifted positions places to the right: those pushed past the end come back at the start.
A negative value shifts to the left. Shifting by the size of the array, or by one of its multiples, leaves it unchanged. The array array is not modified.
arrayRotate([1, 2, 3, 4], 1) // [4, 1, 2, 3]
arrayRotate([1, 2, 3, 4], -1) // [2, 3, 4, 1]
arrayRotate([1, 2, 3, 4], 6) // [3, 4, 1, 2]
arrayRotate([], 3) // []
const array = [1, 2, 3, 4]
const k = ((1 % array.length) + array.length) % array.length
Debug.log(array.slice(array.length - k).concat(array.slice(0, array.length - k))) // [4, 1, 2, 3]
array = [1, 2, 3, 4]
k = 1 % len(array)
Debug.log(array[len(array) - k:] + array[:len(array) - k]) # [4, 1, 2, 3]
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.