Suppose I want to add two lists in Haskell. What is the most usual way to do this?
Here\'s what I did:
addLists :: (Integral a) => [a] -> [a]
There is a zipWith library function that combines two lists by using a supplied function. It does exactly what you want here and you get:
addLists = zipWith (+)
This uses (+) to combine the elements of lists given as further arguments.
(+)