Reference
List
Constructor
| Input | A list of elements separated by comma. |
|---|---|
| Output | A list containing all the elements. |
Signature
[Any, Any, Any, ...]: ListExample
[1, 2, 3] // returns [1, 2, 3]Indexing
| Input | A list and a number representing the index. |
|---|---|
| Output | The element at the specified index in the list. |
Signature
List[Number]: AnyExample
[10, 20, 30][1] // returns 20Filled
| Input | A number and any value. |
|---|---|
| Output | A list filled with the specified value, repeated the specified number of times. |
Signature
list_filled(a: Number, b: Any): ListExample
list_filled(3, 0) // returns [0, 0, 0]At
| Input | A list and a number representing the index. |
|---|---|
| Output | The element at the specified index in the list. |
Signature
list_at(a: List, b: Number): AnyExample
list_at([10, 20, 30], 1) // returns 20First
| Input | A list. |
|---|---|
| Output | The first element of the list. |
Signature
list_first(a: List): AnyExample
list_first([10, 20, 30]) // returns 10Last
| Input | A list. |
|---|---|
| Output | The last element of the list. |
Signature
list_last(a: List): AnyExample
list_last([10, 20, 30]) // returns 30Sublist
| Input | A list and two numbers representing the start and end indices. |
|---|---|
| Output | A new list from the start index (inclusive) to the end index (exclusive). |
Signature
list_sublist(a: List, b: Number, c: Number): ListExample
list_sublist([10, 20, 30, 40], 1, 3) // returns [20, 30]Init
| Input | A list. |
|---|---|
| Output | A new list containing all elements except the last one. |
Signature
list_init(a: List): ListExample
list_init([1, 2, 3]) // returns [1, 2]Rest
| Input | A list. |
|---|---|
| Output | A new list containing all elements except the first one. |
Signature
list_rest(a: List): ListExample
list_rest([1, 2, 3]) // returns [2, 3]Take
| Input | A list and a number. |
|---|---|
| Output | A new list containing the first n elements of the input list, where n is the specified number. |
Signature
list_take(a: List, b: Number): ListExample
list_take([1, 2, 3, 4], 2) // returns [1, 2]Drop
| Input | A list and a number. |
|---|---|
| Output | A new list containing all elements except the first n elements, where n is the specified number. |
Signature
list_drop(a: List, b: Number): ListExample
list_drop([1, 2, 3, 4], 2) // returns [3, 4]Set
| Input | A list, a number, and any value. |
|---|---|
| Output | A new list with the value set at the specified index. |
Signature
list_set(a: List, b: Number, c: Any): ListExample
list_set([1, 2, 3], 1, 99) // returns [1, 99, 3]Concatenation
| Input | Two lists. |
|---|---|
| Output | A new list that is the result of concatenating the two lists. |
Signature
list_concat(a: List, b: List): ListExample
list_concat([1, 2], [3, 4]) // returns [1, 2, 3, 4]Insert start
| Input | A list and any value. |
|---|---|
| Output | A new list with the value inserted at the start. |
Signature
list_insertStart(a: List, b: Any): ListExample
list_insertStart([2, 3], 1) // returns [1, 2, 3]Insert end
| Input | A list and any value. |
|---|---|
| Output | A new list with the value inserted at the end. |
Signature
list_insertEnd(a: List, b: Any): ListExample
list_insertEnd([1, 2], 3) // returns [1, 2, 3]Remove
| Input | A list and an equatable value. |
|---|---|
| Output | A new list with all the occurrences of the value removed. |
Signature
list_remove(a: List, b: Equatable): ListExample
list_remove([1, 2, 3, 2], 2) // returns [1, 3]Remove at
| Input | A list and a number. |
|---|---|
| Output | A new list with the element at the specified index removed. |
Signature
list_removeAt(a: List, b: Number): ListExample
list_removeAt([1, 2, 3], 1) // returns [1, 3]Reverse
| Input | A list. |
|---|---|
| Output | A new list with the elements in reverse order. |
Signature
list_reverse(a: List): ListExample
list_reverse([1, 2, 3]) // returns [3, 2, 1]Flatten
| Input | A list of lists. |
|---|---|
| Output | A new list with nested lists flattened into a single list. |
Signature
list_flatten(a: List): ListExample
list_flatten([[1, 2], [3, 4]]) // returns [1, 2, 3, 4]Distinct
| Input | A list. |
|---|---|
| Output | A new list with duplicate elements removed, preserving order. |
Signature
list_distinct(a: List): ListExample
list_distinct([1, 2, 2, 3, 1]) // returns [1, 2, 3]Chunk
| Input | A list and a number representing the chunk size. |
|---|---|
| Output | A list of lists, each containing at most n elements. |
Signature
list_chunk(a: List, b: Number): ListExample
list_chunk([1, 2, 3, 4, 5], 2) // returns [[1, 2], [3, 4], [5]]Swap
| Input | A list and two numbers. |
|---|---|
| Output | A new list with the elements at the specified indices swapped. |
Signature
list_swap(a: List, b: Number, c: Number): ListExample
list_swap([1, 2, 3], 0, 2) // returns [3, 2, 1]Join
| Input | A list and a string. |
|---|---|
| Output | A string that is the result of concatenating the list elements, separated by the specified string. |
Signature
list_join(a: List, b: String): StringExample
list_join(["a", "b", "c"], ", ") // returns "a, b, c"Length
| Input | A list. |
|---|---|
| Output | The number of elements in the list. |
Signature
list_length(a: List): NumberExample
list_length([1, 2, 3]) // returns 3Is empty
| Input | A list. |
|---|---|
| Output | True if the list is empty. False otherwise. |
Signature
list_isEmpty(a: List): BooleanExample
list_isEmpty([]) // returns trueIs not empty
| Input | A list. |
|---|---|
| Output | True if the list is not empty. False otherwise. |
Signature
list_isNotEmpty(a: List): BooleanExample
list_isNotEmpty([1, 2]) // returns trueContains
| Input | A list and an equatable value. |
|---|---|
| Output | True if the list contains the specified value. False otherwise. |
Signature
list_contains(a: List, b: Equatable): BooleanExample
list_contains([1, 2, 3], 2) // returns trueIndex of
| Input | A list and an equatable value. |
|---|---|
| Output | The index of the first occurrence of the value in the list, or -1 if the value is not found. |
Signature
list_indexOf(a: List, b: Equatable): NumberExample
list_indexOf([10, 20, 30], 20) // returns 1Map
| Input | A list and a function that takes an element of the list as input and returns a new value. |
|---|---|
| Output | A new list with the function applied to each element of the input list. |
Signature
list_map(a: List, b: Function): ListExample
list_map([1, 2, 3], double) // returns [2, 4, 6]Filter
| Input | A list and a function that takes an element of the list as input and returns a boolean. |
|---|---|
| Output | A new list containing only the elements of the input list for which the function returns true. |
Signature
list_filter(a: List, b: Function): ListExample
list_filter([1, 2, 3, 4], isEven) // returns [2, 4]Count
| Input | A list and a predicate function. |
|---|---|
| Output | The number of elements matching the predicate. |
Signature
list_count(a: List, b: Function): NumberExample
list_count([1, 2, 3, 4], num_isEven) // returns 2Reduce
| Input | A list, an initial value, and a function that takes the current value and an element of the list as input and returns a new value. |
|---|---|
| Output | The result of applying the function to each element of the list, starting with the initial value. |
Signature
list_reduce(a: List, b: Any, c: Function): AnyExample
list_reduce([1, 2, 3], 0, num_add) // returns 6All
| Input | A list and a function that takes an element of the list as input and returns a boolean. |
|---|---|
| Output | True if the function returns true for all elements of the list. False otherwise. |
Signature
list_all(a: List, b: Function): BooleanExample
list_all([2, 4, 6], num_isEven) // returns trueNone
| Input | A list and a function that takes an element of the list as input and returns a boolean. |
|---|---|
| Output | True if the function returns false for all elements of the list. False otherwise. |
Signature
list_none(a: List, b: Function): BooleanExample
list_none([1, 3, 5], num_isEven) // returns trueAny
| Input | A list and a function that takes an element of the list as input and returns a boolean. |
|---|---|
| Output | True if the function returns true for at least one element of the list. False otherwise. |
Signature
list_any(a: List, b: Function): BooleanExample
list_any([1, 2, 3], num_isEven) // returns trueZip
| Input | Two lists and a function that takes an element from each list as input and returns a new value. |
|---|---|
| Output | A new list with the function applied to each pair of elements from the input lists. |
Signature
list_zip(a: List, b: List, c: Function): ListExample
list_zip([1, 2], [3, 4], num_add) // returns [4, 6]Sort
| Input | A list and a function that takes two elements of the list as input and compares them. |
|---|---|
| Output | A new list with the elements sorted according to the function. |
Signature
list_sort(a: List, b: Function): ListExample
list_sort([3, 1, 2], num_compare) // returns [1, 2, 3]