0
我知道这个问题之前已经被问过了,但以前的问题都没有答案为我工作,所以我会尝试一种不同的方法。标准ML二叉树数据类型
我已经做到了这一点:
> 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)
啊,谢谢你的帮助。我想我还有很多要了解ML –