colon operator

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 bracket notation [].

base float Starting value of the sequence.

increment float Successively added value to base. It must be positive for an ascending sequence with base <= limit, or negative for a descending sequence with base >= limit. The default is 1.

limit float Maximum or minimum value which is not exceeded.

Returns an array containing the sequence [base, base + increment, base + 2 * increment, ...], where the last element does not exceed limit.

base, increment, and limit are given in colon-separated notation.

The size of the returned array is limited. It can be configured in the Procedural Runtime preferences. The default is 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. Exact values can therefore be unexpected, even if the printed value looks rounded.