我为一个类编写了以下 SML 代码:
fun lookup (cmp: 'a * 'a -> order) (x: 'a, t: 'a tree) : 'a option =
case t of
Empty => NONE
| Node(l,y,r) =>
case cmp(x,y) of
EQUAL => SOME y
| LESS => lookup (cmp) (x,r)
| GREATER => lookup (cmp) (x,l)
在测试中:
val SOME 3 = lookup Int.compare (3, Node(Empty,3,Empty));
并返回以下错误:
stdIn:153.1-166.12 Error: operator and operand don't agree [tycon mismatch]
operator domain: int * int ?.tree
operand: int * int tree
in expression:
(lookup Int.compare) (3,Node (Empty,3,Empty))
是什么?.
意思?