My solution for the problems in http://ocaml.org/learn/tutorials/99problems.html