I'm trying to implement a simple recursive list search in SML/NJ but am getting some errors i dont understand. Here is the code:
fun find x y =
if (null y)
then false
else if x = hd(y)
then true
else find(x, tl(y));
Here are the errors:
stdIn:130.6-135.22 Error: case object and rules don't agree [circularity]
rule domain: ''Z * ''Z list
object: (''Z * ''Z list) * 'Y
in expression:
(case (arg,arg)
of (x,y) =>
if null y
then false
else if <exp> = <exp> then true else find <exp>)
stdIn:130.6-135.22 Error: right-hand-side of clause doesn't agree with function result type [tycon mismatch]
expression: 'Z -> _
result type: bool
in declaration:
find = (fn arg => (fn <pat> => <exp>))
Line 130 is:
fun find x y = (
Any help is greatly apreciated.