
Hello, Sometimes I find that I have two lists I want to combine, but I only want to combine them for as much as I have elements in both lists to combine and then the rest I just want to pass through unmodified. I've now found the following function useful in three different programs I've written: zipWith' :: (a -> a -> a) -> [a] -> [a] -> [a] zipWith' _ [] ys = ys zipWith' _ xs [] = xs zipWith' f (x:xs) (y:ys) = f x y : zipWith' f xs ys Does it already exist or maybe there is another natural solution to use in its place? Thanks, Jason

On Thu, 7 Sep 2006, Jason Dagit wrote:
I've now found the following function useful in three different programs I've written:
zipWith' :: (a -> a -> a) -> [a] -> [a] -> [a] zipWith' _ [] ys = ys zipWith' _ xs [] = xs zipWith' f (x:xs) (y:ys) = f x y : zipWith' f xs ys
Does it already exist or maybe there is another natural solution to use in its place?
I encountered that structure when adding numbers of two lists.
participants (2)
-
Henning Thielemann
-
Jason Dagit