# [Ride v4 and v3] List
⚠️ This is the documentation for the Standard library version 4 and 3. We recommend to use version 6. Go to version 6
List
is a list data type.
The list may contain elements of various types, including nested lists.
The maximim number of list items is 1000. The nesting depth is not limited. For weight restrictions, see the Data Weight article.
# List Operations
Lists support concatenation, as well as adding items to the beginning and the end.
Operation | Symbol | Complexity |
---|---|---|
Concatenation | ++ | 4 |
Adding the element to the end of the list (the list is on the left, the element is on the right) | :+ | 1 |
Adding the element to the beginning of the list (the element is on the left, the list is on the right) | :: | 2 |
⚠️
++
and:+
operators are added in Standard library version 4.
# Example
nil :+ 1 :+ 2 :+ 3
Result: [1, 2, 3]
1 :: 2 :: 3 :: nil
Result: [1, 2, 3]
let intList = [1, 2] # List[Int]
let strList = ["3", "4"] # List[String]
let joined = intList ++ strList # List[Int|String]
joined
Result: [1, 2, "3", "4"]
let appended = joined :+ true # List[Boolean|Int|String]
appended
Result: [1, 2, "3", "4", true]
let nested = intList :: joined # List[Int|List[Int]|String]
nested
Result: [[1, 2], 1, 2, "3", "4"]
# List functions
The built-in list functions are presented in the List Functions article.