Redigera

Dela via


array_rotate_right()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Rotates values inside a dynamic array to the right.

Syntax

array_rotate_right(array, rotate_count)

Learn more about syntax conventions.

Parameters

Name Type Required Description
array dynamic ✔️ The array to rotate.
rotate_count integer ✔️ 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

Dynamic array containing the same elements as the original array with each element rotated according to rotate_count.

Examples

Rotating to the right by two positions:

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

Output

arr arr_rotated
[1,2,3,4,5] [4,5,1,2,3]

Rotating to the left by two positions by using negative rotate_count value:

Results

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

Output

arr arr_rotated
[1,2,3,4,5] [3,4,5,1,2]