I have the following type:
type Rating = (String, Int)
type Film = (String, String, Int, [Rating])
testDatabase :: [Film]
testDatabase = [("Director 1","Film 1",2012,[("TestRat",8)]),("Director 2","Film 2",2,[])]
I need to find out what the average rating of the Director is based on all of their films combined and then all of their ratings combined. I genuinely have no idea how to approach this, I found it hard enough just to get the average of the tuples in the Film let alone work through all of them and do it that way.
My code for working out averages:
filmRating :: [(String,Int)] -> Float
filmRating ratings = average (map snd ratings)
average ratings = realToFrac (sum ratings) / genericLength ratings