Chat on IRC |
SML problem
Posted by cnikolai [send private reply] at May 16, 2003, 04:25:56 PM
I am having a problem with the following SML code; I would like to compare the value of obj with the corresponding second element of the vector tuple elements.
Following is the code: type 'vType vector = (int * 'vType) list fun find (v: ?vType vector, obj: ?vType) = #2(hd(v)))(*works*) fun find2 (v: ?vType vector, obj: ?vType) = obj(*works*) fun find3 (v: ?vType vector, obj: ?vType) = #1(hd(v)) = 1 (*works*) fun find4 (v: ?vType vector, obj:?vType) = #2(hd(v)) = obj (*returns error operator and operand don't agree [ubound match] *) domain: ' 'Z * ' 'Z operand: 'vType * 'vType However, the following code run from another file works and returns true: val testing = Vector.find(myvector, [1,2,3,4,5]); val testing2 = Vector.find2(myvector, [1,2,3,4,5]); val me = (testing = testing2); Does anyone know what the problem is and how to fix it?
Posted by Psion [send private reply] at May 16, 2003, 08:26:19 PM
Read about equality types and you should have your answer.
Register as a new user | ||||