array_split()array_split()

根据拆分索引将数组拆分成多个数组,并将生成的数组打包到一个动态数组中。Splits an array to multiple arrays according to the split indices and packs the generated array in a dynamic array.

语法Syntax

array_split( arr , indices )array_split(arr, indices)

参数Arguments

  • arr :要拆分的输入数组,必须是动态数组。arr: Input array to split, must be dynamic array.
  • indices :具有拆分索引的整数或动态整数数组(从零开始),负值将转换为 array_length + 值。indices: Integer or dynamic array of integers with the split indices (zero based), negative values are converted to array_length + value.

返回Returns

包含 N+1 个数组的动态数组,其值在 arr[0..i1), [i1..i2), ... [iN..array_length) 的范围内,其中 N 是输入索引的数目,i1...iN 是索引。Dynamic array containing N+1 arrays with the values in the range [0..i1), [i1..i2), ... [iN..array_length) from arr, where N is the number of input indices and i1...iN are the indices.

示例Examples

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