This commit is contained in:
Simon Cruanes 2014-05-20 19:52:17 +02:00
parent c5b2373c03
commit 29ff651f3b
2 changed files with 9 additions and 0 deletions

View file

@ -33,9 +33,14 @@ type + 'a t =
let nil = `Nil
let cons a b = `Cons (a,b)
let empty = nil
let singleton x = `Cons (x, fun () -> `Nil)
let is_empty = function
| `Nil -> true
| `Cons _ -> false
let to_list l =
let rec direct i (l:'a t) = match l with
| `Nil -> []

View file

@ -32,10 +32,14 @@ type + 'a t =
val nil : 'a t
val empty : 'a t
val cons : 'a -> (unit -> 'a t) -> 'a t
val singleton : 'a -> 'a t
val is_empty : 'a t -> bool
val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list