I'm trying to convert two textfiles into strings, and then adding them together in double-tuples, in a list. like this: [(_,_),(_,_)]
This is my function:
testa = do
questions <- readFile "questionsQ.txt"
category <- readFile "category.txt"
print (myZip category (lines questions))
myZip :: [a] -> [b] -> [(a, b)]
myZip [] [] = []
myZip _ [] = []
myZip (x:xs) (y:ys) = [(x,y)] ++ myZip xs ys
questions.txt
contains one question per row
categories.txt
contains a line of 50 numbers in a long row, each one representing one of the 5 categories
(Note – it may work at Mac computers, but I don't know why) This is my error message when I try to run the program (some of it at least):
[("0","I prefer variety to routine"),("0",""),("0","I'm an innovative person with a vivid imagination"),("0",""),("0","I enjoy wild flights of fantasy")....
ghci>
*** Exception: todo.hs:(35,1)-(37,44): Non-exhaustive patterns in function myZip
Why does it combine tuples with empty strings? And why is an error message occuring?