Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created November 13, 2009 05:25
Show Gist options
  • Save yaotti/233618 to your computer and use it in GitHub Desktop.
Save yaotti/233618 to your computer and use it in GitHub Desktop.
(* fibonacci *)
let fib(x:int) =
let rec fib_i(n, a, b) =
if n = 1 || n = 2 then a
else fib_i(n-1, a+b, a)
in fib_i(x, 1, 1);;
(* 実行:
# #trace fib;;
fib is now traced.
# fib 4;;
fib <-- 4
fib --> 3
- : int = 3
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment