Solve #22 in Haskell.