array_rotate_right()array_rotate_right()

dynamic 数组中的值向右旋转。Rotates values inside a dynamic array to the right.

语法Syntax

array_rotate_right(arr, rotate_count) array_rotate_right(arr , rotate_count)

参数Arguments

  • arr:要拆分的输入数组,必须是动态数组。arr : Input array to split, must be dynamic array.
  • rotate_count:整数,用于指定数组元素将向右旋转的位置数。rotate_count : Integer specifying the number of positions that array elements will be rotated to the right. 如果该值为负数,则元素将向左旋转。If the value is negative, the elements will be rotated to the left.

返回Returns

所包含元素数与原始数组中的元素数相同的动态数组,其中每个元素根据 rotate_count 进行旋转。Dynamic array containing the same amount of the elements as in the original array, where each element was rotated according to rotate_count.

请参阅See also

示例Examples

  • 向右旋转两个位置:Rotating to the right by two positions:

    print arr=dynamic([1,2,3,4,5]) 
    | extend arr_rotated=array_rotate_right(arr, 2)
    
    arrarr arr_rotatedarr_rotated
    [1,2,3,4,5][1,2,3,4,5] [4,5,1,2,3][4,5,1,2,3]
  • 使用负 rotate_count 值向左旋转两个位置:Rotating to the left by two positions by using negative rotate_count value:

    print arr=dynamic([1,2,3,4,5]) 
    | extend arr_rotated=array_rotate_right(arr, -2)
    
    arrarr arr_rotatedarr_rotated
    [1,2,3,4,5][1,2,3,4,5] [3,4,5,1,2][3,4,5,1,2]