structure Tree = struct exception Missing; datatype 'label tree = Node of 'label * 'label tree list; (* create a one-node tree *) fun create(a) = Node(a,nil); (* build a tree from a label and a list of trees *) fun build(a,L) = Node(a,L); (* find the ith subtree of a tree *) fun subtree(i,Node(a,nil)) = raise Missing | subtree(1,Node(a,t::ts)) = t | subtree(i,Node(a,t::ts)) = subtree(i-1,Node(a,ts)); end; signature SIMPLE = sig exception Missing; datatype 'label tree = Node of 'label * 'label tree list; val build : int * int tree list -> int tree; val subtree : int * int tree -> int tree end; structure SimpleTree: SIMPLE = Tree; open SimpleTree; val t2 = build(2,nil); val t3 = build(3,nil); val t1 = build(4,nil); val t4 = build(1,[t1,t2,t3]); subtree(2,t4);