The revised function
fun for(start, step, test, f, x) =
if test(start)
then for(step(start), step, test,
f, f(start, x))
else x
Example of use:
- fun incr(n) = n+1
- fun less100(n) = n
- fun plus(m, n) = m+n
- val x = for(0, incr, less100, plus, 0)
(* x = 4950 *)