Recursive user-defined datatypes
Node of int * int_tree * int_tree;
- fun insert x Empty = Node(x,Empty,Empty)
| insert x (n as Node(y,t1,t2)) = if x = y then n else if x < y then Node(y,insert x t1,t2) else Node(y,t1,insert x t2);
val insert = fn : int -> int_tree -> int_tree;
- fun member x Empty = false | member x (Node(y,t1,t2)) = if x = y then true else if x < y then member x t1 else member x t2;
val member = fn : int -> int_tree -> bool;