Hi folks. I decided to learn a functional language in order to increase my programming knowledge and was advised to learn Haskell. I didn't find any useful books, so one of my friends (former software engineering student) gave me his class notes, including tons of exercises.
However, he claimed he "lost" the solutions for the said exercises because they were stored in a pen, which he forgot where he placed it. :(
I'm having a hard time to get this function to work because the error message is confusing (which is my main Haskell pet peeve).
In this case, I just want a simple thing, I want to sum two lists.
And so I wrote down:
sum2lists :: [Int] -> [Int] -> [Int]
sum2lists list1 list2
| null list2 = list2
| list1 null = list1
| otherwise = head list1 + head list2 : (sum2lists tail(list1) tail(list2))
However, everytime I try to run the program I get the following error message:
ERROR file:.\sum2lists.hs:4 - Type error in application
*** Expression : list1 null
*** Term : list1
*** Type : [Int]
*** Does not match : a -> b
I already Google'd but found nothing useful.
P.S: Do you know any good Haskell books, especially with solved exercises and such? For sites, I usually visit haskell.org and zvon.org.
Thanks for your time!