Find limit of recursion: Difference between revisions

added ocaml
(added ocaml)
Line 222:
print error ; 16 Stopping... recurse [make "depth :depth + 1]
(print [Depth reached:] :depth) ; some arbitrarily large number</lang>
 
 
=={{header|OCaml}}==
When the recursion is a "[[:Category:Recursion|tail-recursion]]" there is no limit.
Which is important because being a functional programming language, OCaml uses recursion to make
loops.
 
If the recursion is not a tail one, the execution is stopped with the message
"Stack overflow":
<lang ocaml># let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067</lang>
 
here we see that the function call stack size is 262067.
 
 
=={{header|Oz}}==