I am trying to make a sorting function for unique large numbers in SML but the compiler keeps setting my function type to int instead of 'a. How can I explicitly tell the compiler to use IntInf?
Here is my code:
fun selectsort([a]) = [a]
| selectsort(h::t) =
if (hd(selectsort(t))) < h then hd(selectsort(t))::h::tl(selectsort(t))
else h::selectsort(t);
when I try
fun selectsort([a]) = [a]
| selectsort(l : IntInf list) =
if (hd(selectsort(tl(l)))) < hd(l) then hd(selectsort(tl(l)))::h::tl(selectsort(tl(l)))
else hd(l)::selectsort(tl(l));
it keeps giving me "Error: unbound type constructor: IntInf"
IntInf
is the name of a module, the type is namedIntInf.int
. Alas, your code somewhat simplified:Note however that
IntInf
is an optional module that is not available on all implementations. (Also, you should add a case for the empty list.)