array initialization function

Syntax

float[]/string[]/bool[]  [value, value, ...]

float[]/string[]/bool[]  [value, value, ... ; value, value, ... ; ...]

Parameters

Returns

An array containing all elements in the specified arrangement. The type of the array depends on the type of value. For example, a float[] array can be made from a mixture of float and float[] values.

Description

1D array

An array can be initialized by the concatenation of primitive values separated by comma:

const a = ["B", "C", "D"]
(3)[B,C,D]
Beside primitive values, also arrays can be used to create new arrays:
const b = ["A", a, "E"]
(5)[A,B,C,D,E]

2D array

Primitive values and/or arrays can be arranged in several rows separated by semicolon:
const a = [-1 ; -2]
(2x1)
   -1
   -2
const b = [0:2 ; 3, 3, 3]
(2x3)
   0   1   2
   3   3   3
const c = [a, b ; b, a]
(4x4)
   -1   0   1    2
   -2   3   3    3
    0   1   2   -1
    3   3   3   -2

The size of the returned array is limited. It can be configured in the Procedural Runtime preferences (Default: 100000).

Empty arrays can be created using floatArray, boolArray and stringArray.

Related

Examples

Fibonacci numbers

fibonacci(n) = case n <= 2 : [0:n-1] 
               else        : fibonacci([0,1], n)
 
fibonacci(a, n) = case size(a) == n : a
                  else              : fibonacci([a, a[size(a)-2] + a[size(a)-1]], n)

Lot --> print(fibonacci(10))  // (10)[0,1,1,2,3,5,8,13,21,34]

Copyright ©2008-2023 Esri R&D Center Zurich. All rights reserved.