I am new to Haskell and Stackoverflow, and I am trying to teach Haskell programming, and I am doing a series of exercises from a book that I downloaded, and I was wondering if you guys could help me here.
I am trying to write an avgPub function that returns the average of all years of publication for a series of books. Function arguments: avgPub :: [(String, String, Int)] → Int. An example of I / O is
> avgPub [("publisher", "book", 1920), ("publisher1", "book1", 1989), ("publisher2", "book2", 1920)]
1943
Yesterday I found out about div, sum and map, but I'm not sure how to tie it all together for this problem (as the exercise hints). I think that in order to find the average value of the Ints list, you make a list (x:xs) = (sum (x:xs))div length, but we are not only dealing with Ints, so this will not work.
I find it difficult to figure out how to tie it all together.
source
share