Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions