Commit c709b941 authored by Jean-Christophe's avatar Jean-Christophe

snapshotable trees with additional comments

parent 9936d6ea
......@@ -7,6 +7,8 @@ Hannes Mehnert, Filip Sieczkowski, Lars Birkedal, and Peter Sestoft
VSTTE 2012
*)
(* Purely applicative binary trees with elements at the nodes *)
theory Tree
use export int.Int
......@@ -14,8 +16,6 @@ theory Tree
use export list.Length
use export list.Append
(* binary trees with elements at the nodes *)
type elt = int
type tree =
......@@ -34,12 +34,12 @@ theory Tree
end
(* Purely applicative iterators over binary trees *)
module Enum
use import Tree
(* the left spine of a tree, as a bottom-up list *)
type enum =
| Done
| Next elt tree enum
......@@ -49,8 +49,6 @@ module Enum
| Next x r e -> Cons x (tree_elements r ++ enum_elements e)
end
(* the enum of a tree [t], prepended to a given enum [e] *)
let rec enum t e variant { length (tree_elements t) } =
{ }
match t with
......@@ -61,6 +59,8 @@ module Enum
end
(* Mutable iterators with a Java-like API *)
module Iterator
use import Tree
......@@ -87,6 +87,8 @@ module Iterator
end
(* Binary search trees *)
module BSTree
use export Tree
......@@ -114,6 +116,7 @@ module BSTree
{ result=True <-> mem x t }
exception Already
(* bst_add raises exception Already when the element is already present *)
let rec bst_add (x: elt) (t: tree) =
{ bst t }
......@@ -130,6 +133,8 @@ module BSTree
end
(* Imperative trees with add/contains/snapshot/iterator API *)
module ITree
use export module BSTree
......@@ -189,7 +194,6 @@ module Harness
()
done
end
(*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment