- let rec add t x =
- match t with
- | Leaf -> Node (x, Leaf, Leaf)
- | Node (x', left, right) when x < x' -> Node (x', add left x, right)
- | Node (x', left, right) when x > x' -> Node (x', left, add right x)
- | (Node _) as t' -> t'
-
- let rec member t x =
- match t with
- | Leaf -> false
- | Node (x', left, _) when x < x' -> member left x
- | Node (x', _, right) when x > x' -> member right x
- | Node _ -> true