Arrays

Arrays are lists of values.

The following table describes the list of functions available for Arrays:

Table 1. Arrays

Expression

Description

ArrayCreate(...elements): []

Returns an array with the provided elements.

ArrayGetItem(array: Array, index: number)

Returns the item at the indicated index value in the array. Note that the first element will have an index value of 0.

ArrayConcat(array: Array, ...values)

Return a new array that adds the provided values to the end of the existing array.

ArrayCount(array: Array)

Returns the number of elements in the array.

ArrayJoin(array: Array, separator: string)

Returns a string with all the elements in the array. If the separator is provided, it is returned between each array element.

ArrayFilter(array: Array, expression: string)

Applies the expression provided against all elements in the array and returns a new array with only elements returning true when evaluated against the expression.

ArrayFind(array: Array, expression: string)

Returns the first element in the array, which returns true when evaluated against the expression.

ArrayIncludes(array: Array, expression: string): Boolean

Returns true if the array includes an element that returns true when evaluated against the expression. Otherwise, returns false.

ArraySlice(array: Array, start: number, end: number): Array

Returns a new array starting at the index provided in the start and ending at the index before the value provided in the end or until the end of the array is reached. If an end is not provided, all elements from the start index until the end of the array are returned.

ArrayInsert(array: Array, items: Array, start: number): Array

Insert the items into the array at the position indicated by the start. If no start value is provided, the items are appended to the end of the array.

Creation

There are two ways to create an array. The array can be directly assigned with members, as in the following examples:

array1 = (a, b, c)

array2 = (True, “abc”, 5)

The function ArrayCreate can also be used to create an array, as in the following examples:

array3 = ArrayCreate(a, b, c)

array4 = ArrayCreate(True, “abc”, 5)

Note: The arrays can contain items of different value types.

Membership

x in (a, b, c)

x not in (a, b, c)

It is possible to check whether an element is included in an array using the in operator. For example, x in (a, b, c) will return True if the value of variable x is a, b, or c. Otherwise, it will return False.

Using not in provides the reverse functionality, where True is returned if the value of the variable is not in the array; otherwise, False is returned.

Element Access

There are two ways to access elements of an array. The element can be directly accessed by the index value, such as myArray[2]. If the array is defined as myArray = (a, b, c), myArray[2] has the value of c. Note that array indices begin with 0.

The function ArrayGetItem can also be used to access an element of an array. The following example returns the third element in myArray: ArrayGetItem(myArray, 2)

Appending items

Elements can be appended to an array using the function ArrayConcat. Multiple items can be added at the same time. The following example adds d, e, and f to myArray: ArrayConcat(myArray, d, e, f)

Length

The function ArrayCount returns the length of the array.

ArrayCount(array: Array(any)): number