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

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) // true
The 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.