module Ilist: sig
.. end
Imbricated lists
The operations of this module have a functional semantics.
type 'a
el =
| |
Atome of 'a |
| |
List of 'a t |
Type of list elements.
type 'a
t = 'a el list
Type of imbricated lists.
val cons : 'a el -> 'a t -> 'a t
Adding a new list element at the begining of the list
val atome : 'a -> 'a el
Create a list element from a single element.
val list : 'a t -> 'a el
Create a list element from a list.
val of_list : 'a list -> 'a t
Create a recursive list from a list
val hd : 'a t -> 'a el
Return the head of the list.
val tl : 'a t -> 'a t
Return the tail of the list.
val length : 'a t -> int
Return the ength of the list.
val depth : 'a t -> int
Return the (maximal) depth of the list.
depth [] = 0
depth [a;b;c] = 1
depth [[a];b] = 2
val append : 'a t -> 'a t -> 'a t
Append two lists
val flatten : ?depth:int -> 'a t -> 'a t
Flatten the recursive list, but only starting from the given
depth. Defaut depth is 1.
flatten [] = []
flatten [a;[b;[c];d];e;[f]] = [a;b;c;d;e;f]
flatten ~depth:2 [a;[b;[c];d];e;[f]] = [a;[b;c;d];e;[f]]
flatten ~depth:3 [a;[b;[c];d];e;[f]] = [a;[b;[c];d];e;[f]]
val rev : 'a t -> 'a t
Recursively reverse the recursive list
rev [a;[b;[c];d];e;[f]] = [[f];e;[d;[c];b];a]
val mem : 'a -> 'a t -> bool
Membership test.
val exists : ('a -> bool) -> 'a t -> bool
Existence test
val map : (bool -> 'a -> 'b) -> 'a t -> 'b t
Ordinary map function.
The boolean value indicates whether the element is beginning
a recursive list.
val iter : (bool -> 'a -> unit) -> 'a t -> unit
Ordinary iteration function.
The boolean value indicates whether the element is beginning
a recursive list.
val fold_left : ('a -> bool -> 'b -> 'a) -> 'a -> 'b t -> 'a
Ordinary fold function, from left to right.
val fold_right : (bool -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
Ordinary fold function, from right to left.
val print : ?first:(unit, Format.formatter, unit) Pervasives.format ->
?sep:(unit, Format.formatter, unit) Pervasives.format ->
?last:(unit, Format.formatter, unit) Pervasives.format ->
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit
Printing function.