List
_::_
Add an element at the top of a list.
Type:
('a, ['a]) -> ['a]
Arguments:
(unlabeled)(of type'a)(unlabeled)(of type['a])
_[_]
l[k] returns the first v such that (k,v) is in the list l (or "" if no such v exists).
Type:
(['a * string], 'a) -> string where 'a is an orderable type
Arguments:
(unlabeled)(of type['a * string] where 'a is an orderable type)(unlabeled)(of typeanything that is an orderable type)
list.add
Add an element at the top of a list.
Type:
('a, ['a]) -> ['a]
Arguments:
(unlabeled)(of type'a)(unlabeled)(of type['a])
list.append
Concatenate two lists.
Type:
(['a], ['a]) -> ['a]
Arguments:
(unlabeled)(of type['a])(unlabeled)(of type['a])
list.case
Define a function by case analysis, depending on whether a list is empty or not.
Type:
(['a], 'b, (('a, ['a]) -> 'b)) -> 'b
Arguments:
(unlabeled)(of type['a]): List to perform case analysis on.(unlabeled)(of type'b): Result when the list is empty.(unlabeled)(of type('a, ['a]) -> 'b): Result when the list is non-empty.
list.ind
Define a function by induction on a list. This is slightly more efficient than defining a recursive function. The list is scanned from the right.
Type:
(['a], 'b, (('a, ['a], 'b) -> 'b)) -> 'b
Arguments:
(unlabeled)(of type['a]): List to perform induction on.(unlabeled)(of type'b): Result when the list is empty.(unlabeled)(of type('a, ['a], 'b) -> 'b): Result when the list is non-empty, given the current element, the tail and the result of the recursive call on the tail.
list.init
Initialize a list.
Type:
(int, ((int) -> 'a)) -> ['a]
Arguments:
(unlabeled)(of typeint): Number of elements in the list.(unlabeled)(of type(int) -> 'a): Function such thatf iis theith element.
list.iteri
Call a function on every element of a list, along with its index.
Type:
(((int, 'a) -> unit), ['a]) -> unit
Arguments:
(unlabeled)(of type(int, 'a) -> unit)(unlabeled)(of type['a])
list.length
Compute the length of a list, i.e., the number of its elements.
Type:
(['a]) -> int
Arguments:
(unlabeled)(of type['a])
list.map
Map a function on every element of a list.
Type:
((('a) -> 'b), ['a]) -> ['b]
Arguments:
(unlabeled)(of type('a) -> 'b)(unlabeled)(of type['a])
list.nth
Get the n-th element of a list (the first element is at position 0), or default if element does not exist.
Type:
(?default : 'a?, ['a], int) -> 'a
Arguments:
default(of type'a?, which defaults tonull): Default element. Raiseserror.not_foundifnulland no element can be found in the list.(unlabeled)(of type['a])(unlabeled)(of typeint)
list.remove
Remove the first occurrence of a value from a list.
Type:
('a, ['a]) -> ['a]
Arguments:
(unlabeled)(of type'a)(unlabeled)(of type['a])
list.rev
Revert list order.
Type:
(['a]) -> ['a]
Arguments:
(unlabeled)(of type['a])
list.shuffle
Shuffle the content of a list. The function returns a list with the same elements but in different, random, order.
Type:
(['a]) -> ['a]
Arguments:
(unlabeled)(of type['a])
list.slice
Return the sublist of length length starting with the element at index offset.
Type:
(?offset : int, ?length : int?, ['a]) -> ['a]
Arguments:
offset(of typeint, which defaults to0): Index of the first element.length(of typeint?, which defaults tonull): Length of the returned list. Include all elements fromoffsetifnull.(unlabeled)(of type['a])
list.sort
Sort a list according to a comparison function.
Type:
((('a, 'a) -> int), ['a]) -> ['a]
Arguments:
(unlabeled)(of type('a, 'a) -> int): Comparison function f such that f(x,y)<0 when x<y, f(x,y)=0 when x=y, and f(x,y)>0 when x>y.(unlabeled)(of type['a]): List to sort.