陣列左旋轉()

使用 版本 下拉選單切換服務。 了解更多關於導航的資訊。
Apply to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel

將陣列內的 dynamic 值旋轉到左邊。

語法

array_rotate_left( array、 rotate_count)

深入瞭解 語法慣例。

參數

姓名 類型 必要 描述
陣列 dynamic ✔️ 要旋轉的陣列。
rotate_count 整數 ✔️ 陣列專案將旋轉到左邊的位置數目。 如果值為負數,元素會旋轉到右邊。

傳回

動態陣列,包含與原始數位相同的元素,每個元素都會根據 rotate_count旋轉。

範例

下列範例顯示旋轉到左邊兩個位置:

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

輸出

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

下列範例示範使用負rotate_count值,以兩個位置向右旋轉:

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

輸出

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