Bewerken

Delen via


array_rotate_left()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Rotates values inside a dynamic array to the left.

Syntax

array_rotate_left(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 left. If the value is negative, the elements will be rotated to the right.

Returns

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

Examples

Rotating to the left by two positions:

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

Output

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

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

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

Output

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