# ARRAY¶

One-dimensional array of one primitive type data. The ARRAY object is most commonly used when parsing repeated elements from the source data (see Array).

LITERAL NOTATION: enclose data elements in square brackets, separated by a comma:

```[0, 2, 3]
```

## Accessing ARRAY elements¶

 ```1 2 3 4 5 6``` ```int_array = [1,2,3,4,5] int_array[0] // => 1 first element ARRAY_SELECT(int_array, 0) int_array[4] // => 5 last element ARRAY_SELECT(int_array, 4) ```

## Converting to ARRAY¶

 `1` ```dual(5) | select(ARRAY_AGG(i)); ```

## Comparing ARRAYs¶

```a=[1, 2]
b=[1, 2, 3]

a > b   // => FALSE
a = b   // => FALSE
a < b   // => TRUE

c=['a', 'b']
d=['c','d']

c > d   // => FALSE
c = d   // => FALSE
c < d   // => TRUE
```

## ARRAY Functions¶

```a = [3,2,5,1,4,null]

ARRAY_AVG(a)            // => 3.0
ARRAY_COUNT(a)          // => 5
ARRAY_CONCAT_AGG(a)     // => [3,2,5,1,4,null]
ARRAY_IDX(a, 2)         // => 1
ARRAY_JOIN(a, ";")      // => "3;2;5;1;4;NULL"
ARRAY_LEN(a)            // => 6
ARRAY_MAX(a)            // => 5
ARRAY_MIN(a)            // => 1
ARRAY_REMOVE_NULLS(a)   // => [3, 2, 5, 1, 4]
ARRAY_SELECT(a, 2, 4)   // => [5, 1, 4, NULL]
ARRAY_SORT(a)           // => [1, 2, 3, 4, 5, NULL]
ARRAY_SUM(a)            // => 15.0
```

## Parsing ARRAYs¶

Parsing integers:

```1,2,3,4,5
```
 `1` ```ARRAY{INT:i ','?}*:arr ```