1 module Array = ArrayLabels
8 val add : 'a t -> 'a -> 'a t
10 val member : 'a t -> 'a -> bool
13 module BinaryTree : TREE = struct
15 | Node of 'a * 'a t * 'a t
22 | Leaf -> Node (x, Leaf, Leaf)
23 | Node (x', left, right) when x < x' -> Node (x', add left x, right)
24 | Node (x', left, right) when x > x' -> Node (x', left, add right x)
25 | (Node _) as t' -> t'
30 | Node (x', left, _) when x < x' -> member left x
31 | Node (x', _, right) when x > x' -> member right x
39 ~init:BinaryTree.empty
40 ~f:(fun t str -> BinaryTree.add t str)
42 Printf.printf "%B\n" (BinaryTree.member tree "a")