This post originated from an RSS feed registered with Java Buzz
by Brian McCallister.
Original Post: OCaml does #!, wheee!
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
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:~$ ./fibtest.ml
89
brianm@kite:~$
Maybe I need to spend less time with parens and more time with bizarre semicolon rules...