我想为SML中的唯一大数制作排序函数,但编译器一直将我的函数类型设置为int而不是'a。我怎样才能明确地告诉编译器使用IntInf?SML如何显式设置函数参数类型为IntInf
这里是我的代码:
fun selectsort([a]) = [a]
| selectsort(h::t) =
if (hd(selectsort(t))) < h then hd(selectsort(t))::h::tl(selectsort(t))
else h::selectsort(t);
当我尝试
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));
它不断给我 “错误:未绑定类型的构造:IntInf”
使用变通方法求解:'if(hd(choicesort(t))+ IntInf.fromInt(0))
2014-12-07 16:08:49