Hello,

Many texts explain the following Fibonacci code:

fibs :: [Integer]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

But this code is very slow because evaluation of (+) is done
lazily. If we have the following strict zipWith', the code above
becomes much faster.

zipWith' f (a:as) (b:bs) = x `seq` x : zipWith' f as bs
  where
    x = f a b
zipWith' _ _ _ = []

Data.List defines foldl' against foldl. But it does not define
zipWith'. I'm curious why zipWith' does not exist in the standard
libraries.

--Kazu

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to