List Library (List)
Linked with the "list" type.
Example Usage
#[main]
fn main() {
const array = [1, 2, 3];
assert_eq(array.len(), 3);
assert_eq(List.len(array), 3);
}List.any(array: list) -> bool
Does this list contain any values?
const array = [1];
assert(array.any());List.append(array: list, other: list) -> void
Append another list to this list, leaving other unmodified.
const array = [1, 2, 3];
array.append([4, 5]);
assert_eq(array, [1, 2, 3, 4, 5]);List.at(array: list, index: int) -> unknown
Get the value at the given index, optionally by reference.
List.back(array: list) -> unknown
Get the value at the back of this list, optionally by reference.
List.clear(array: list) -> void
Clear all values from this list.
List.contains(array: list, value: unknown) -> bool
Does this list contain the given value?
List.empty(array: list) -> bool
Is this list empty?
List.front(array: list) -> unknown
Get the value at the front of this list, optionally by reference.
List.index_of(array: list, v: unknown) -> int
If the list contains the given value, return the index of the first matched value. Returns -1 if the list does not contain the given value.
List.insert(array: list, index: int, val: unknown) -> void
Insert a value into this list at the given index.
List.is_uniform(array: list) -> bool
Returns true if every value in this list has the same specific type (does not account for object prototype inheritance).
List.join(array: list, sep: str) -> str
Join the values in this array together into a single string.
List.len(array: list) -> int
Return the length of this list.
List.pop_back(array: list) -> unknown
Remove a single value from the back of this list and return it.
List.pop_front(array: list) -> unknown
Remove a single value from the front of this list and return it.
List.push_back(array: list, ..) -> void
Push N values to the back of this list.
List.push_front(array: list, ..) -> void
Push N values to the front of this list.
List.remove(array: list, index: int) -> unknown
Remove a value at the given index and return it. Returns null if index is out of bounds.
List.remove_all(array: list, val: unknown) -> bool
Remove all occurrances of a value in this array (equals) and return true if any were removed.
List.remove_first(array: list, val: unknown) -> unknown
Remove the first occurrance of a value in this array (equals) and return it.
List.remove_last(array: list, val: unknown) -> unknown
Remove the last occurrance of a value in this array (equals) and return it.
List.replace(array: list, index: int, val: unknown) -> unknown
Replace/set the value at the given index with a new value, returning the old.
List.reverse(array: list) -> void
Reverses this list in-place.
List.reversed(array: list) -> list
Return a new list that is reversed, leaving this list unmodified.
List.sort(array: list) -> void
Sort the values in this array according to their already defined ordering.
List.to_uniform(array: list, type: str) -> void
Try casting all values in this list to the given type (given as a string like you would in a Stof file). Will throw an error if a value cannot be cast.
Last updated