type List a = | Nil | Cons a * List a
| Name | Fixity | Type | Description |
|---|---|---|---|
| nil | [a] List a | the empty list | |
| null | [a] List a -> Boolean | true for empty lists | |
| length | List a -> Nat | length of a list | |
| cons | [a] a * List a -> List a | constructs a list consisting of a first element and a list tail | |
| insert | [a] a * List a -> List a | same as cons | |
| hd | [a] List a -> a | returns the first element of the list | |
| tl | [a] List a -> List a | returns the list tail without the first element | |
| ++ | L 25 | [a] List a * List a -> List a | list concatenation |
| concat | [a] List a * List a -> List a | prefix op for list concatenation | |
| flatten | [a] List(List(a)) -> List a | returns the concatenation of the list elements | |
| diff | [a] List a * List a -> List a | list subtraction: diff(x,y) returns a list containing the elements of x that are not in y, preserving the order of the elements in x | |
| member | [a] a * List a -> Boolean | list membership | |
| nth | [a] List a * Nat -> a | nth(x, n) returns the element at position n of list x, counting from 0 | |
| nthTail | [a] List a * Nat -> List a | nthTail(x, n) returns the tail of list x, starting after position n, counting from 0 | |
| sublist | [a] List a * Nat * Nat -> List a | sublist(x, m, n)]] returns the tail of list x, from position m up to but not including n, counting from 0 | |
| foldl | [a,b] (a*b -> b) -> b -> List a -> b | foldl f e x successively applies function f to the elements of list x from left to right. The second argument to f is initially e and at each next step the result of the previous invocation of f | |
| foldr | [a,b] (a*b -> b) -> b -> List a -> b | like foldl, but the elements of the list are processed from right to left | |
| map | [a,b] (a -> b) -> List a -> List b | applies function to each element of a list and returns the list consisting of the results | |
| mapPartial | [a,b] (a -> Option b) -> List a -> List b | like map but replacing each result Some y by y and deleting None results. | |
| filter | [a] (a -> Boolean) -> List a -> List a | returns the list of elements satisfying the given predicate | |
| rev | [a] List a -> List a | reverse list | |
| all | [a] (a -> Boolean) -> List a -> Boolean | true if all elements of the list satisfy the predicate given as first parameter | |
| exists | [a] (a -> Boolean) -> List a -> Boolean | true if some element of the list satisfies the predicate given as first parameter | |
| find | [a] (a -> Boolean) -> List a -> Option(a) | returns Some x where x is the first element in the list (from left to right) for which the given predicate yields true; if no such element exists, None is returned | |
| tabulate | [a] Nat * (Nat -> a) -> List a | tabulate(n, f) returns the list [f(0), f(1), ... , f(n-1)] | |
| firstUpTo | [a] (a -> Boolean) -> List a -> Option (a * List a) | returns Some(e, x) where e is the first element in the list (from left to right) satisfying the given predicate and x the initial list segment preceding e; if no such element exists, None is returned | |
| splitList | [a] (a -> Boolean) -> List a -> Option (List a * a * List a) | returns Some(x, e, y) where e is the first element in the list (from left to right) satisfying the given predicate, x the initial list segment preceding e, and y the list tail following e; if no such element exists, None is returned | |
| locationOf | [a] List a * List a -> Option (Nat * List a) | locationOf(s, t) returns Some(n, x) where n is the first position in list t (counting from from left to right) where list s occurs as a contiguous sublist, and x the list tail segment following s in t; if s does not occur in t, None is returned | |
| compare | [a] (a * a -> Comparison) -> List a * List a -> Comparison | compares two list using the comparison function given as first parameter | |
| show | [a] String -> List String -> String | show(s, x) returns the element strings in x concatenated, with string s inserted between any two elements |