Preface_core.Nonempty_list
A Non empty list. The module allows to deal with non-empty list. Lists where the minimum size is one.
val create : 'a -> 'a t
create x
create a new non-empty list with x
.
val from_list : 'a list -> 'a t option
Creates a non-empty list from a regular list.
val to_list : 'a t -> 'a list
Convert non-empty list to a regular list.
val hd : 'a t -> 'a
Returns the head of a non-empty list.
val length : 'a t -> int
Returns the length of a non-empty list.
rev_append a b
is a tail-recursive version of append (rev a) b
.
val iter : ('a -> unit) -> 'a t -> unit
List
.iter for non-empty list.
val iteri : (int -> 'a -> unit) -> 'a t -> unit
List
.iteri for non-empty list.
val reduce : ('a -> 'a -> 'a) -> 'a t -> 'a
reduce f xs
reduce all value of xs
into one.
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
List
.fold_left for non-empty list.
val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b
List
.fold_right for non-empty list.
val pp :
(Stdlib.Format.formatter -> 'a -> unit) ->
Stdlib.Format.formatter ->
'a t ->
unit
Formatter for pretty-printing for Nonempty_list.t
.