我知道以前有人问过这个问题,但是以前的问题中没有一个答案对我有用,所以我会尝试不同的方法。
我已经这样做了:
> datatype which = STRING of string | INT of int;
datatype which = INT of int | STRING of string
> datatype whichTree = Empty | Leaf of which | Node of whichTree*whichTree;
datatype whichTree = Empty | Leaf of which | Node of whichTree * whichTree
但是当我尝试建造一棵树时
> val mytree = Node(Leaf(which 2), Leaf(which 6));
我得到错误。
Error-Value or constructor (which) has not been declared Found near
Node( Leaf(which(2)), Leaf(which(6)))
Error-Value or constructor (which) has not been declared Found near
Node( Leaf(which(2)), Leaf(which(6)))
Static errors (pass2)