array initialization function

Syntax

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

Parameters

1. valueâ€”(float, float[], string, string[] ,bool, bool[] )
Array element values. At least one element must be specified.

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 a 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 a 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``````

Example

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]``````