This seems to be homework, so I give you a partial solution and some hints only. The type you want is a 'a * 'a -> int
, so the skeleton of a suitable function could be something like this (I assume you are using Standard ML):
fun foo(x, y) = ???
The ???
needs to meet two requirements: it must contain an expression that forces x
and y
to have the same type, and it must return an integer. The latter shouldn't be hard. For the former, there are many possibilities in SML, e.g., putting them in the same list, or returning them from the branches of the same if
or case
or handle
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…