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 –