Skip to content

Instantly share code, notes, and snippets.

@lg0
lg0 / fibonacci.sml
Last active December 26, 2015 00:39
Standard ML
(* Traditional (not tail-recursive) *)
fun fibonacci n =
case n of
0 => 0
| 1 => 1
| _ => fibonacci(n-1) + fibonacci(n-2)
(* tail-recursive *)
fun fbnc_tail n =
let fun aux (n, n_1, n_2) =