Evaluates the function
argument on all values in the array under the
array
argument overwriting
the array. If the asArray
argument is supplied, then array:eval()
saves the
result in an array under the given prefix. This overwrites existing arrays
of that name.
The output array is always compacted, meaning that the array indices are
guaranteed to be continuous, i.e. 0,1,2,...
.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
array [a] | string | required | The array name in LogScale Array Syntax, for example for events with fields incidents[0], incidents[1], ... this would be incidents[] , as in array:eval(array="incidents[]", ... . | |
asArray | string | optional[b] | value passed to the array parameter | The output array. |
function | Non-aggregate function | required | The function to be applied to each element of the array. Must write a value to a field named the same as the output array. | |
var | string | optional[b] | input array name | Name of the variable to be used in the function argument. |
[b] Optional parameters use their default value unless explicitly set. |
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
array
can be omitted; the following forms of this function are equivalent:logscalearray:eval("value[]",function="value")
and:
logscalearray:eval(array="value[]",function="value")
These examples show basic structure only.
array:eval()
Examples
To square the value of each item in the array:
values [0] = 2
values [1] = 3
values [2] = 4
Use the following query function:
array:eval("values[]", asArray="squared[]", var=v, function={squared :=v*v})
The expected output is:
field | value |
---|---|
squared[0] | 4 |
squared[1] | 9 |
squared[2] | 16 |