### The array module contains functions to work for arrays. ## Returns the length of `array`. ## ## Returns an `integer`. intrinsic fn len(array) as array::len; ## Returns if `array` is empty. ## ## Returns an `bool`. intrinsic fn is_empty(array) as array::is_empty; ## Returns if `array` contains an `element`. ## ## Returns an `bool`. intrinsic fn contains(array, element) as array::contains; ## Adds an `element` to the end of `array`. ## ## Returns an `array`. intrinsic fn push(array, element) as array::push; ## Zips two arrays, returning a new array of tuples for the first element ## being part of the left array and the second element part of the right ## array. ## ## **Note**: left and right need to have the same length. ## ## > ```tremor ## > let left = [1, 2, 3]; ## > let right = ["a", "b", "c"]; ## > array::zip(left, right) == [[1, "a"], [2, "b"], [3, "c"]] ## > ``` ## ## Returns an `array`. intrinsic fn zip(left, right) as array::zip; ## Unzips an array of tuples into an array of two arrays. ## ## **Note**: array's elements need to be arrays of two elements. ## ## > ```tremor ## > array::unzip([[1, "a"], [2, "b"], [3, "c"]]) == [[1, 2, 3], ["a", "b", "c"]] ## > ``` ## ## Returns an `array`. intrinsic fn unzip(array) as array::unzip; ## Flattens a nested array recursively. ## ## > ```tremor ## > array::flatten([[1, 2, 3], ["a", "b", "c"]]) = [1, 2, 3, "a", "b", "c"] ## > ``` ## ## Returns an `array`. intrinsic fn flatten(array) as array::flatten; ## Returns the array for null values removed. ## ## > ```tremor ## > array::coalesce([1, null, 2, null, 3]) = [1, 2, 3] ## > ``` ## ## Returns an `array`. intrinsic fn coalesce(array) as array::coalesce; ## Joins the elements of an array (turing them into Strings) for a given ## separator. ## ## > ```tremor ## > array:join(["this", "is", "a", "cake"], " ") => "this is a cake" ## > ``` ## ## Returns a `string`. intrinsic fn join(array, string) as array::join; ## Concatenates two arrays returning a new array. The new array is not a set, ## i.e. it can contain duplicates depending on the input arrays. ## ## > ```tremor ## > array::concatenate([1, 2, 3], [3, 4]) == [1, 2, 3, 3, 4] ## > ``` ## ## Returns an `array` intrinsic fn concatenate(left, right) as array::concatenate; ## Sorts an array ## ## > ```tremor ## > array::sort([3, 2, 3, 1, 4]) == [1, 2, 3, 3, 4] ## > ``` ## ## Returns an `array` intrinsic fn sort(array) as array::sort; ## Reverses an array ## ## > ```tremor ## > array::reverse([3, 2, 3, 1, 4]) == [4, 1, 3, 2, 3] ## > ``` ## ## Returns an `array` intrinsic fn reverse(array) as array::reverse;