list - How to create a recursive zipWith function in Haskell? -


so far have:

mizipwith f [] [] = [] mizipwith f (x:xs) [] = [] mizipwith f [] (y:ys) = [] mizipwith f (x:xs) (y:ys) = f y: mizipwith f xs ys  ----mizipwith f (x:xs) (y:ys) = f x : f y : mizipwith f xs ys 

but "zips" function f second list. how include first list too?

*main> mizipwith (*2) [1,2,3,4] [5,6,1] [10,12,2] 

the zipwith function goes this:

zipwith :: (a -> b -> c) -> [a] -> [b] -> [c] zipwith f (x:xs) (y:ys) = f x y : zipwith f xs ys zipwith _ _ _ = [] 

your assumption function f takes 1 argument, in fact takes 2 (the head of both lists).