Dynamic programming in Haskell using laziness and zipWith.