real
is not an equality type in ML, and so neither are polymorphic types constructed from real
s -- in particular, real list
s are not equality types, and so you cannot use the operator =
to compare two real list
s, even if those lists are empty. Instead, you need to pattern match. For example,
fun reverse [] = []
| reverse (x::xs) = (reverse xs) @ [x]
or
fun reverse [] = []
| reverse (x::xs) = case xs of
[] => [x]
| _ => (reverse xs) @ [x]
will work even for nonequality types.
(Alternately, use the built in function List.rev
.)