colon operator
Syntax
float[]  base : limit
float[]  base : increment : limit
The colon operator is only available as a parameter for the array initialization function and the index operator (inside a bracket [] notation).
Parameters
- base (float)
Starting value of sequence. - increment (float)
Successively added value to base. Must be positive for an ascending sequence base<=limit or negative for a descending sequence base>=limit. Default is 1. - limit (float)
Maximum/minimum value which is not exceeded.
Returns
An array containing a sequence of float values
[ base, base + increment, base + 2*increment, ... ]where the last element does not exceed limit.
Parameters base, increment and limit are given in a colon-separated notation.
The size of the returned array is limited. It can be configured in the Procedural Runtime preferences (Default: 100000).
Related
Examples
Binary colon operator
const a = [2 : 4] // (3)[2,3,4] const b = [0.5 : 3] // (3)[0.5,1.5,2.5] const c = [4 : 2] // (0)[]
Ternary colon operator
const a = [1 : 0.5 : 3] // (5)[1,1.5,2,2.5,3] const b = [4 : -1 : 2] // (3)[4,3,2] const c = [1 : -0.5 : 2] // (0)[] const d = [1 : -0.5 : 1] // (1)[1] const e = [1 : 0 : 1] // (0)[]
Floating point imprecision
const a = [0 : 0.15 : 0.5] Init --> print(a) // (4)[0,0.15,0.3,0.45] print(a[3] == 0.45) // false print(abs(a[3] - 0.45) < 1e-10) // trueThe computation of sequence values base+i*increment suffers from floating point imprecision. Their exact values might be unexpected. This is not always noticable when printing values due to an implicit rounding.
Copyright ©2008-2024 Esri R&D Center Zurich. All rights reserved.