Tutorial: How to trace a function in OCaml

Tutorial: How to trace a function in OCaml.

asked Sep 4, 2013 by anonymous

1 Answer

 
Best answer

Use #trace. For example, to trace function f:

# let rec f n = if n = 0 then 1 else f (n - 1) * n;;
val f : int -> int = <fun>
# #trace f;;
f is now traced.
# f 4;;
f <-- 4
f <-- 3
f <-- 2
f <-- 1
f <-- 0
f --> 1
f --> 1
f --> 2
f --> 6
f --> 24
- : int = 24
answered Sep 4, 2013 by anonymous

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...