Reference on lists.
RefList is a extended set of functions that manipulate list references.
Adds an element in a sorted list, using optional comparator or 'compare' as default.
Removes and returns the first element or
raises Empty_list
if the ref list is empty
Removes and returns the n first elements or
raises Empty_list
if the ref list does not
contain enough elements
Apply the given function to all elements of the ref list, in respect with the order of the list
Find the first element matching
the specified predicate
raise Not_found
if no element is found
Find the first element in the reversed ref list matching
the specified predicate
raise Not_found
if no element is found
Same as find but takes an exception to be raised when no element is found as additional parameter
Return true
if all elements match the specified
predicate
Apply a function to all elements and return the list constructed with the function returned values
Sort elements using the specified comparator or compare as default comparator
Remove all elements that do not match the specified predicate
Remove an element from the ref list
raise Not_found
if the element is not found
Remove the first element matching the
specified predicate
raise Not_found
if no element has been removed
Remove all elements equal to the specified element from the ref list
Functions that operate on the i
th element of a list.
While it is sometimes necessary to perform these
operations on lists (hence their inclusion here), the
functions were moved to an inner module to prevent
their overuse: all functions work in O(n) time. You
might prefer to use Array
or DynArray
for constant
time indexed element access.
Return the index (position : 0 starting) of an element in
a ref list, using ( = ) for testing element equality
raise Not_found
if no element was found
Return the index (position : 0 starting) of an element in
a ref list, using the specified comparator
raise Not_found
if no element was found
Return the element of ref list at the specified index
raise Invalid_index
if the index is outside 0 ; length-1