[Haskell-cafe] How to improve the running time of my algorithm