Untitled
public text v1 · immutablefun tnpl i j =
let
fun res 1 : IntInf.int = 1
| res i : IntInf.int =
let
val (x,y) = IntInf.divMod(i,2)
in
if (y=0) then 1 + res x
else 1 + res (3*i+1)
end
in
let
fun mklist i j =
if (i<=j) then (res i) :: mklist (i+1) j
else nil
in
let
fun max nil = 0
| max [a] = a
| max (h::t) =
let
val m = max t
in
if (h>m) then h
else m
end
in
max (mklist i j)
end
end
end;