Recursive Functions in ML
fun fact n = if n = 0 then 1
else n * fact (n-1);
val fact = fn : int -> int
fact 5;
val it = 120
fact 100;
uncaught exception overflow
raised at <file stdin>
Previous slide
Next slide
Back to first slide
View graphic version