(** Returns Some [x] if [x] is the head of the list, or None for the empty list. Runs in O(1). *)
valhead:'alist->'aoption
(** Returns the tail of the list. Will be the empty list if the original list is empty or only contains one element. Runs in O(1). *)
valtail:'alist->'alist
(** Reverses the order of the elements in the list. [reverse] is tail recursive. Runs in O(n). *)
valreverse:'alist->'alist
(** Appends two lists together, by reversing the first and then appending each element from the first to the second. Runs in O(n), where n is the length of the first list. *)
val(@):'alist->'alist->'alist
(** Maps the given function to each element of the list. [map] is not tail recursive and preserves order. Runs in O(n). *)
valmap:('a->'b)->'alist->'blist
(** Maps the given function to each element of the list. [map_rev_tr] is tail recursive and reverses the order of the list. If you wish to preserve order consider [map] for small lists, and [map_tr] for longer lists. Runs in O(n). *)
valmap_rev_tr:('a->'b)->'alist->'blist
(** Maps the given function to each element of the list. [map_tr] is tail recursive, and therefore has to reverse the resulting list. Calling [map_tr] is equivalent to calling [reverse] on the result of [map_rev_tr]. Runs in O(n). *)
valmap_tr:('a->'b)->'alist->'blist
(** Folds the list from the left, applying [f] to the existing state and each element at each step, using [init] as the initial state. [foldl] is tail recursive. Runs in O(n). *)
valfoldl:('s->'a->'s)->'s->'alist->'s
(** Folds the list from the right, by reversing the list and then calling [foldl]. Runs in O(n). *)
valfoldr:('s->'a->'s)->'s->'alist->'s
(** Combines two lists into a list of tuples, pairing elements in order and returning a list of pairs in reverse order compared to the original lists. [zip2_rev_tr] is tail recursive. Returns result type to handle errors where the two lists are not equal in length. Runs in O(n). *)
valzip2_rev_tr:'alist->'blist->('a*'b)listresult
(** Combines two lists into a list of tuples, pairing elements in order from the front. [zip2_rev_tr] is tail recursive. Returns result type to handle errors where the two lists are not equal in length. This is equivalent to reversing the result of [zip2_rev_tr]. Runs in O(n). *)
valzip2_tr:'alist->'blist->('a*'b)listresult
(** Converts a list of tuples into a tuple of lists, reversing the order of the elements in the resulting two lists. Runs in O(n). *)
valunzip2_rev_tr:('a*'b)list->'alist*'blist
(* Returns all adjascent pairs of values from the list, as well as a pair of the last element and the first element. Runs in O(n). *)
valpairwise:'alist->('a*'a)list
(** Determines if the specified element is contained within the list, and returns a boolean. Runs in O(n). If this function is being called many times, consider a Set. *)
valcontains:'a->'alist->bool
(** Creates a list of a single element. Runs in O(1). *)
valsingleton:'a->'alist
(** Filters a list according to the provided function, including elements where the function evaluates to true. The list is reversed in the process, and [filter_rev_tr] is tail recursive. Runs in O(n). *)
valfilter_rev_tr:('a->bool)->'alist->'alist
(** Finds the first element in the provided list where the given function evaluates to true. Returns Some of the element and the index it appeared at, or none if the given function is false for all elements. Runs in O(n). *)
valfind:('a->bool)->'alist->('a*int)option
(** Initializes a list using a length and a function from the index to the desired list value. Runs in O(n). *)