In the online book by Robert Harper (Programming Standard ML, on page 88, we have the following definition of a binary tree:
datatype 'a tree =
Leaf
| Node of 'a branch * 'a branch
and 'a branch =
Branch of 'a * 'a tree;
I wanted to create the following example tree (that conforms to the above definition of a tree)
10
/ \
5 11
/ \
2 6
I am strugglig to create the root node. What I've got so far is:
val two = Branch (2, Leaf);
val six = Branch (6, Leaf);
val eleven = Branch (11, Leaf);
val five = Branch (5, Node (two, six));
val ten = Branch (10, Node (five, eleven));
But then ten isn't the root of the tree. How'd I form the root of this tree?
datatype 'a tree = Leaf | Node of 'a * 'a tree * 'a tree