Question: I need to create some functions in Haskell. The types are: type Person = String type Book = String type Database = [ (Person, [Book])
I need to create some functions in Haskell.
The types are:
type Person = String
type Book = String
type Database = [ (Person, [Book]) ]
The functions are:
makeLoan :: Database -> Person -> Book -> Database
#makeLoan adds a book to a persons list of books updates the database
returnLoan :: Database -> Person -> Book -> Database
# returnLoan removes a book from a persons list of books updates the database
books :: Database -> Person -> [Book]
#books returns a list of the books a person is borrowing
borrowers :: Database -> Book -> [Person]
#borrowers returns a list of people who are borrowing a book
borrowed :: Database -> Book -> Bool
#borrowed checks if a book is checked out
numBorrowed :: Database -> Person -> Int
#numBorrowed checks how many books a person has checked out
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
