Prelude_extracted.ListThis module contains many safe functions for manipulating lists.
type 'a t = 'a listval empty : 'a listval is_empty : 'a list -> boolTest whether a list is empty
val return : 'a -> 'a listSingleton list
val hd : 'a list -> 'aPartial function to access the head of the list. This function will fail when applied to the empty list. NOTE it is recommended to rely on pattern matching instead
Partial function to access the tail of the list. This function will fail when applied to the empty list NOTE it is recommended to rely on pattern matching instead
List append / concatenation. append l1 l2 returns a list composed of all elements of l1, followed by all elements of l2
val length : 'a list -> Imandrax_util.Z.tCompute the length of a list. Linear time.
Length of a list is non-negative. This useful theorem is installed as a forward-chaining rule.
A list has length zero iff it is empty. This is a useful rewrite rule for obtaining empty lists.
The length of (x @ y) is the sum of the lengths of x and y
Map a function over a list.
map f [] = []map f [x] = [f x]map f (x :: tail) = f x :: map f tailfor_all f l tests whether all elements of l satisfy the predicate f
exists f l tests whether there is an element of l that satisfies the predicate f
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'aFold-left, with an accumulator that makes induction more challenging
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'bFold-right, without accumulator. This is generally more friendly for induction than fold_left.
filter f l keeps only the elements of l that satisfy f.
find f l returns Some x if x is the first element of l such that f x is true. Otherwise it returns None
val mem : 'a -> 'a list -> boolmem x l returns true iff x is an element of l
val mem_assoc : 'a -> ('a * 'b) list -> boolval nth : Imandrax_util.Z.t -> 'a list -> 'a optiontake n l returns a list composed of the first (at most) n elements of l. If length l <= n then it returns l
drop n l returns l where the first (at most) n elements have been removed. If length l <= n then it returns []
Integer range. i -- j is the list [i; i+1; i+2; …; j-1]. Returns the empty list if i >= j.
Insert x in l, keeping l sorted.
val is_sorted : leq:('a -> 'a -> bool) -> 'a list -> boolCheck whether a list is sorted, using the leq less-than-or-equal predicate