无论如何要组合这两个函数,它们需要一个列表并返回最高和最低元素。想要同时输出。欢呼声SML将两个函数(最小值,最大值)合并为一个(范围)
fun max[] = raise Empty
max[x] = x
max(x::xs) =
let
val y = max xs
in
if x > y then x else y
end;
fun min[] = raise Empty
min[x] = x
min(x::xs) =
let
val y = min xs
in
if x < y then x else y
end;