Haskell Lists - zip 2
I want to write a function that concatenates two lists. I have the following code:
zip' :: [a]->[b]->[(a,b)]
zip' _ [] = []
zip' [] _ = []
zip' (x:xs)(y:ys)=(x,y) zip'(xs ys)
The problem is that when I compile the code, I get a lot of errors
Could not match expected type [b] -> t0 to actual type a
The xs function is applied to one argument
Any ideas what I am doing wrong? Sorry if this might seem like a silly question.
source to share
Any ideas what I am doing wrong?
Code
(x,y) zip'(xs ys)
means: take a function (x,y)
and apply it to two arguments, the first one is zip'
and the second is the result of the function being applied xs
to ys
.
Since it is (x,y)
not a function, this generates a type error. Also, xs
it is not a function, so another type of error will be thrown by its application.
source to share