More recursive solutions in Haskell, Erlang and Scala