# [Ride v5] List functions
⚠️ This is the documentation for the Standard library version 5. We recommend to use version 6. Go to version 6
| Name | Description | Complexity | 
|---|---|---|
| cons(A, List[B]): List[A|B] | Inserts element to the beginning of the list | 1 | 
| containsElement(List[T], T): Boolean | Check if the element is in the list | 5 | 
| getElement(List[T], Int): T | Gets the element from the list | 2 | 
| indexOf(List[T], T): Int|Unit | Returns the index of the first occurrence of the element in the list | 5 | 
| lastIndexOf(List[T], T): Int|Unit | Returns the index of the last occurrence of the element in the list | 5 | 
| max(List[Int]): Int | Returns the largest element in the list of integers | 3 | 
| max(List[BigInt]): BigInt | Returns the largest element in the list of big integers | 192 | 
| min(List[Int]): Int | Returns the smallest element in the list of integers | 3 | 
| min(List[BigInt]): BigInt | Returns the smallest element in the list of big integers | 192 | 
| removeByIndex(List[T], Int): List[T] | Removes an element from the list by index | 7 | 
| size(List[T]): Int | Returns the size of the list | 2 | 
A, B, T means any valid type.
# cons(A, List[B]): List[A|B]
Inserts element to the beginning of the list.
cons(head:T, tail: List[T]): List[T]
# Parameters
| Parameter | Description | 
|---|---|
head: T |  Element | 
tail: List[T] |  List | 
# Examples
cons("Ride", ["on", "Waves"]) # Returns ["Ride", "on", "Waves"]
cons(1, [2, 3, 4, 5]) # Returns [1, 2, 3, 4, 5]
# containsElement(List[T], T): Boolean
Check if the element is in the list.
containsElement(list: List[T], element: T): Boolean
# Parameters
| Parameter | Description | 
|---|---|
list: List[T] |  List | 
element: T |  Element to search for | 
# getElement(List[T], Int): T
Gets the element from the list by index.
getElement(arr: List[T], pos: Int): T
# Parameters
| Parameter | Description | 
|---|---|
arr: List[T] |  List | 
pos: Int |  Index of the element | 
# Examples
getElement(["Ride", "on", "Waves"], 0)  # Returns "Ride"
getElement([false, true], 1) # Returns true
# indexOf(List[T], T): Int|Unit
Returns the index of the first occurrence of the element in the list or unit if the element is missing.
indexOf(list: List[T], element: T): Int|Unit
# Parameters
| Parameter | Description | 
|---|---|
list: List[T] |  List | 
element: T |  Element to locate | 
# Example
let stringList = ["a","b","a","c"]
indexOf("a", stringList) # Returns 0
# lastIndexOf(List[T], T): Int|Unit
Returns the index of the last occurrence of the element in the list or unit if the element is missing.
lastIndexOf(list: List[T], element: T): Int|Unit
# Parameters
| Parameter | Description | 
|---|---|
list: List[T] |  List | 
element: T |  Element to locate | 
# Example
let stringList = ["a","b","a","c"]
lastIndexOf("a", stringList) # Returns 2
# max(List[Int]): Int
Returns the largest element in the list of integers. Fails if the list is empty.
max(List[Int]): Int
# Parameters
| Parameter | Description | 
|---|---|
list: List[Int] |  List | 
# max(List[BigInt]): BigInt
Returns the largest element in the list of big integers. Fails if the list is empty.
max(List[BigInt]): BigInt
# Parameters
| Parameter | Description | 
|---|---|
list: List[BigInt] |  List | 
# min(List[Int]): Int
Returns the smallest element in the list of integers. Fails if the list is empty.
min(List[Int]): Int
# Parameters
| Parameter | Description | 
|---|---|
list: List[Int] |  List | 
# min(List[BigInt]): BigInt
Returns the smallest element in the list of big integers. Fails if the list is empty.
min(List[BigInt]): BigInt
# Parameters
| Parameter | Description | 
|---|---|
list: List[BigInt] |  List | 
# removeByIndex(List[T], Int): List[T]
Removes an element from the list by index.
removeByIndex(list: List[T], index: Int): List[T]
# Parameters
| Parameter | Description | 
|---|---|
list: List[T] |  List | 
index: T |  Index of the element | 
# Example
removeByIndex(["Waves", 42, true], 1) # Returns ["Waves", true]
# size(List[T]): Int
Returns the size of the list.
size(arr: List[T]): Int
# Parameters
| Parameter | Description | 
|---|---|
arr: List[T] |  List | 
# Examples
size(["Ride", "on", "Waves"]) # Returns 3