Solved first problem in Haskell.