Module Ilist


module Ilist: sig .. end
Imbricated lists


The operations of this module have a functional semantics.

type 'a el =
| Atome of 'a (*Terminal case*)
| List of 'a t (*The element is recursively a list.*)
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.
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.
val rev : 'a t -> 'a t
Recursively reverse the recursive list
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.