package containers

  1. Overview
  2. Docs
type 'a t = 'a list Stdlib.ref
val push : 'a t -> 'a -> unit

push rlist e adds an element e at the head of rlist.

val pop : 'a t -> 'a option

pop rlist removes and returns Some e (the first element of rlist) or None if the rlist is empty

val pop_exn : 'a t -> 'a

pop_exn rlist removes and returns the first element of rlist. Unsafe version of pop.

  • raises Failure

    if the list is empty.

val create : unit -> 'a t

create () creates a new empty reference list.

val clear : _ t -> unit

clear rlist removes all elements of rlist.

val lift : ('a list -> 'b) -> 'a t -> 'b

lift f rlist applies a list function f to the content of rlist.

val push_list : 'a t -> 'a list -> unit

push_list rlist l adds elements of the list l at the beginning of the list ref rlist. Elements at the end of the list l will be at the beginning of the list ref rlist.

OCaml

Innovation. Community. Security.