Brian's Waste of Time

Fri, 10 Jun 2005

OCaml does #!, wheee!

I needed to write something that ran fast, so tried to remember my ocaml. Realized that I didn't remember much, so started just playing. Learned something cool:

#!/usr/bin/env ocaml
let rec fibonacci n =
   if n < 2 then 1
   else fibonacci (n - 1) + fibonacci (n - 2);;  
print_int (fibonacci 10);
print_string "\n"

Does what you want it too:

brianm@kite:~$ ./ 

Maybe I need to spend less time with parens and more time with bizarre semicolon rules...

0 writebacks [/src] permanent link