Applies f to every element of the list and returns the new list.
((a) -> b, list<a, n>) -> list<b, n>
f : (a) -> b | The mapping function |
lst : list<t, n> | The list to map. |
The list obtained by applying f to every element of lst.
Applies a function f to each element of the list, threading an accumulator argument through the computation.
((t, state) -> state, state, list<t, n>) -> state
f : (t, state) -> state | The function to update the state given the input elements. |
initState : state | The initial state. |
lst : list<t, n> | The input list. |
The final state value.
Applies a function f to each element of the list in reverse order, threading an accumulator argument through the computation.
((t, state) -> state, state, list<t, n>) -> state
f : (t,state) -> state | The function to update the state given the input elements. |
initState : state | The initial state. |
lst : list<t, n> | The input list. |
The final state value.
Applies a function f to each element of the list in order, threading an accumulator argument through the computation. The initial accumulator is the first element of the list.
((t, t) -> t, list<t, n>) -> t
f : (t, t) -> t | The function to update the accumulator, given an element from the list as the first parameter, and the accumulator as the second parameter. |
lst : list<t, n> | The list to reduce over. |
The final accumulated value.
Applies a function f to each element of the list in order, threading an accumulator argument through the computation. The initial accumulator is the first element of the list if the length is greater than zero. If the list has length 0, nothing() is returned.
((t, t) -> t, list<t, n>) -> maybe<t>
f : (t, t) -> t | The function to update the accumulator, given an element from the list as the first parameter, and the accumulator as the second parameter. |
lst : list<t, n> | The list to reduce over. |
The final accumulated value if the length was greater than 0, and nothing() otherwise.
Applies a function f to each element of the list in reverse order, threading an accumulator argument through the computation. The initial accumulator is the last element of the list.
((t, t) -> t, list<t, n>) -> t
f : (t, t) -> t | The function to update the accumulator, given an element from the list as the first parameter, and the accumulator as the second parameter. |
lst : list<t, n> | The list to reduce over. |
The final accumulated value.
Applies a function f to each element of the list in reverse order, threading an accumulator argument through the computation. The initial accumulator is the last element of the list if the length is greater than zero. If the list has length 0, nothing() is returned.
((t, t) -> t, list<t, n>) -> maybe<t>
f : (t, t) -> t | The function to update the accumulator, given an element from the list as the first parameter, and the accumulator as the second parameter. |
lst : list<t, n> | The list to reduce over. |
The final accumulated value if the length was greater than 0, and nothing() otherwise.
Concatenates two lists.
(list<t, aCap>, list<t, bCap>) -> list<t, retCap>
lstA : list<t, aCap> | The first list. |
lstB : list<t, bCap> | The second list. |
The two lists appended together.
Concatenates two lists, always allocating enough space in the return list to hold the items.
(list<t, aCap>, list<t, bCap>) -> list<t, aCap + bCap>
lstA : list<t, aCap> | The first list. |
lstB : list<t, bCap> | The second list. |
The two lists appended together.
Returns the nth element of the given list
(u, list<t, n>) -> t where u : int
i : u | The index of the element to be retrieved |
lst : list<t, n> | The given list |
The element at position i in the list
Returns the nth element of the given list, or nothing if the index is out of bounds
(uint32, list<t, n>) -> maybe<t>
i : uint32 | The index of the element to be retrieved |
lst : list<t, n> | The given list |
The element at position i in the list inside a just, or nothing if the index is out of bounds.
Flattens a list of lists into a single list.
(list<list<t, m>, n>) -> list<t, retCap>
listOfLists : list<list<t, m>, n> | The list of lists |
The flattened list
Flattens a list of lists into a single list.
(list<list<t, m>, n>) -> list<t, m*n>
listOfLists : list<list<t, m>, n> | The list of lists |
The flattened list
Creates a copy of the list which has a new capacity m. The contents and length of the list remained unchanged. Note that you can specify the output capacity m by using a type constraint at the call site.
(list<t, n>) -> list<t, m>
lst : list<t, n> | The list to resize |
The new list with capacity m
Returns true if pred(elem) returns true for all elements elem in lst, otherwise false.
((t) -> bool, list<t, n>) -> bool
pred : (t) -> bool | The predicate which must be satisfied |
lst : list<t, n> | The list on which the predicate is checked |
A boolean value which determines if pred satsified for every element of lst.
Returns true if pred(elem) returns true for at least one element elem in lst, otherwise false.
((t) -> bool, list<t, n>) -> bool
pred : (t) -> bool | The predicate which must be satisfied |
lst : list<t, n> | The list on which the predicate is checked |
A boolean value which determines if pred is satsified for some element of lst.
Mutates the given list with the element appended to the end. If the element will not fit in the list, nothing is inserted.
(t, inout list<t, n>) -> list<t, n>
elem : t | The element to add to the end of the list |
lst : inout list<t, n> | The list |
A copy of lst with elem appended to the end
Returns a copy of the given list with the element appended to the end. If the element will not fit in the list, nothing is inserted.
(t, list<t, n>) -> list<t, n>
elem : t | The element to add to the end of the list |
lst : list<t, n> | The list |
A copy of lst with elem appended to the end
Returns a copy of the given list with the element appended to the end.
(t, list<t, n>) -> list<t, n + 1>
elem : t | The element to add to the end of the list |
lst : list<t, n> | The list |
A copy of lst with elem appended to the end
Mutates a list, adding and element to the front. If the list is already full then the last element is pushed off (removed) from the back of the list.
(t, inout list<t, n>) -> unit
elem : t | The element to add to the front of the list |
lst : inout list<t, n> | The list |
unit
Returns a copy of the given list with the element prepended to the front. If the list is already full then the last element is pushed off (removed) from the back of the list.
(t, list<t, n>) -> list<t, n>
elem : t | The element to add to the front of the list |
lst : list<t, n> | The list |
A copy of lst with elem prepended to the front
Mutates the given list where the element at the given index is the given element. If the index is out of bounds the list remains unchanged.
(uint32, t, inout list<t, n>) -> unit
index : uint32 | The index to set |
elem : t | The new element |
lst : inout list<t, n> | The list |
unit
Returns a copy of the given list where the element at the given index is the given element. If the index is out of bounds the list remains unchanged.
(uint32, t, list<t, n>) -> list<t, n>
index : uint32 | The index to set |
elem : t | The new element |
lst : list<t, n> | The list |
A new list where the elem is at index.
Initializes a new list of a given length using the given element.
(uint32, t) -> list<t, n>
numOfElements : uint32 | The length of the new list |
elem : t | The element to replicate |
A new list with elem at every position in the list.
Mutates the input list where the first element equal to elem is deleted, if there is such an element.
(t, list<t, n>) -> unit
elem : t | The element to remove from the list |
lst : t | The list to mutate |
unit
Returns a copy of lst where the first element equal to elem is deleted, if there is such an element.
(t, list<t, n>) -> list<t, n>
elem : t | The element to remove from the list |
lst : t | The list |
A copy of lst with elem removed.
Mutates and drops the last element of a List. If the list has size 0, the list remains unchanged
(inout list<t, n>) -> unit
lst : list<t, n> | The list |
unit
Drops the last element of a List in a copy. If the list has size 0, the list remains unchanged
(list<t, n>) -> list<t, n>
lst : list<t, n> | The list |
The list with the last element dropped
Calls f for each element in lst. This function is used for its side effects and the evaluation order is defined to be the same as the order of the elements in the list.
((t) -> unit, list<t, n>) -> unit
f : (t) -> unit | The function to call |
lst : list<t, n> | The list |
Unit
Returns the last element of the lst.
(list<t, n>) -> t
lst : list<t, n> | The list |
The last element of the list
Returns the last element of the lst.
(list<t, n>) -> maybe<t>
lst : list<t, n> | The list |
The last element of the list if the length is greater than 0, or nothing otherwise.
Returns the maximum element of the lst. If the list is empty, nothing() is returned.
(list<t, n>) -> maybe<t> where t : num
lst : list<t, n> | The list |
The maximum element of the list
Returns the minimum element of the lst. If the list is empty, nothing() is returned.
(list<t, n>) -> maybe<t> where t : num
lst : list<t, n> | The list |
The minimum element of the list
Returns true if elem is a member of lst, otherwise false.
(t, list<t, n>) -> bool
elem : t | The element to match |
lst : list<t, n> | The list to search |
True if elem is in the list, otherwise false.
Zips two lists of equal length into one list of two-tuples, where the first element of each tuple is taken from the first list & the second element is taken from corresponding element in the second list. If the lists are not of equal length, the elements from the longer list are dropped.
(list<a, n>, list<b, n>) -> list<(a,b), n>
lstA : list<a, n> | The first list to zip |
lstB : list<b, n> | The second list to zip |
The zipped lists.
Unzips a list of two-tuples into two lists, where the first list contains the first element of each tuple, & the second list contains the second element of each tuple.
(list<(a*b), n>) -> (list<a, n>*list<b, n>)
lst : list<(a*b), n> | The list to unzip |
The two unzipped lists.
Computes the sum of a list of numbers
(list<a, n>) -> a where a : num
lst : list<a, n> | The list to sum |
The sum of the list
Computes the average (mean) of a list of numbers
(list<a, n>) -> a where a : num
lst : list<a, n> | The list to average |
The numerical mean of the list
Sorts a list in place using the heapsort algorithm. The heapsort algorithm was chosen since it uses no recursion, making it nice for embedded systems, and it still runs in O(n log n) time.
((t) -> m, inout list<t, n>) -> unit where m : num
key : (t) -> m | The key function to use for sorting. Elements will be ordered according to what is returned by the key function. |
lst : inout list<t, n> | The list to sort in place. |
unit
Creates a new list that is sorted using the heapsort algorithm.
((t) -> m, list<t, n>) -> list<t, n> where m : num
key : (t) -> m | The key function to use for sorting. Elements will be ordered according to what is returned by the key function. |
lst : list<t, n> | The list to sort. |
The sorted list.