Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Coursework
There is a single coursework in this module, counting for 30% of the overall module mark.
This coursework is due at 5pm on Sunday 5th December. As with all modules, this deadline is
hard. (See “Submission” below for the extension procedure.)
This coursework provides practice with Haskell and the use of containers. This task does not
require any material presented after session 6, and I do not expect to see it in your solutions.
The task
You are to write a number of functions that perform queries on a list of customer ratings of
products, represented by the type Rating defined as
type Customer = String
type Product = String
type Score = Int
type Rating = (Customer, Product, Score)
The functions to be defined are:
customers :: [Rating] -> [Customer]
a list of all customers who submitted a rating, without duplicates. (10%)
products :: [Rating] -> [Product]
a list of all products that have been rated, without duplicates. (10%)
numScores :: [Rating] -> [(Customer, Int)]
customers and the number of products they have rated. (20%)
consistent :: [Rating] -> [Customer]
a list of the customers who give the same score in all their ratings. (20%)
averageScore :: [Rating] -> [(Product, Double)]
the average score of each product. (20%)
popular :: [Rating] -> [Product]
the products that have each been rated by every customer. (20%)
I have supplied a skeletal module Ratings.hs. You must not change the declarations in
that file (I will rely on them for automatic testing) but you can add whatever else you like.
The proportional value of each function is given above. Your implementations will be as-
sessed for correctness, clarity and effective use of Haskell, the container libraries and other ap-
propriate library functions.