I am quite new to SML and am trying to implement a selection sort. I am running into an uncaught empty error however and can't seem to see why.
fun removeMin lst =
let
val (m, l) = removeMin(tl lst)
in
if null (tl lst) then
(hd lst, [])
else if hd lst < m then
(hd lst, tl lst)
else
(m, hd lst::l)
end;
fun selectionSort [] = []
| selectionSort lst =
let
val (m, l) = removeMin(lst)
in
m::selectionSort(l)
end;
I would appreciate suggestions as to where my mistake is and how to fix it.