Hére is a summary of that table: • A recipient can receive blood from anyone with the same blood type. A person with O- blood can be a donor for anyone. A person with AB+ blood can receive blood from anyone. • Additonally, a person with AB- blood can receive blood from a donor with B- or A- blood. Additonally, a person with A+ blood can receive blood from a donor with O+ or A- blood. • Additonally, a person with B+ blood can receive blood from a donor with O+ or B- blood. • No other combination of donor and recipient blood types is compatible. For this question, we will use symbols to represent each blood type. The symbol will match the types described above. So for example, the O+ blood type w will be one of the blood types described above. Write a function compatible-litres in Racket that consumes a list of symbols, blood-bank, and a symbol, blood-type. Each element in blood-bank reE and blood-type represents the blood type of a blood transfusion recipient. The function produces the total number of litres available for donation for some bank. For example: * 1 > (compatible-litres (list '0- '0+ '0- 'B- 'AB-) 'AB-) 2 2 3> (compatfible-litres (list 'A+ 'B+) 'A-) 4 0 5 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+) 6 1.5
Hére is a summary of that table: • A recipient can receive blood from anyone with the same blood type. A person with O- blood can be a donor for anyone. A person with AB+ blood can receive blood from anyone. • Additonally, a person with AB- blood can receive blood from a donor with B- or A- blood. Additonally, a person with A+ blood can receive blood from a donor with O+ or A- blood. • Additonally, a person with B+ blood can receive blood from a donor with O+ or B- blood. • No other combination of donor and recipient blood types is compatible. For this question, we will use symbols to represent each blood type. The symbol will match the types described above. So for example, the O+ blood type w will be one of the blood types described above. Write a function compatible-litres in Racket that consumes a list of symbols, blood-bank, and a symbol, blood-type. Each element in blood-bank reE and blood-type represents the blood type of a blood transfusion recipient. The function produces the total number of litres available for donation for some bank. For example: * 1 > (compatible-litres (list '0- '0+ '0- 'B- 'AB-) 'AB-) 2 2 3> (compatfible-litres (list 'A+ 'B+) 'A-) 4 0 5 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+) 6 1.5
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Question 1: Blood Donation
For this question you will be writing a program to solve the same problem as Question 2 from Assignment 4. However, as described at the beginning of the assignment specification your solution for this assignment must not use explicit recursion.
Since the purpose, contract, and examples would be identical to the solution for the Assignment 4. However, you are encouraged to properly document and fully test your solution. You are welcome to use code and tests from the model solution in your submission for this question.
Here is the problem specification.
Hospitals rely on donors to provide blood for people who are in accidents or scheduled for surgery. However, people have different blood types, and some blood types are compatible for donation and others are not. There are eight different blood types: O-, O+, B-, B+, A-, A+, AB-, AB+
The rules for blood donations are shown in a table from the Canadian Blood Services website.
Here is a summary of that table:
* A recipient can receive blood from anyone with the same blood type.
* A person with O- blood can be a donor for anyone.
* A person with AB+ blood can receive blood from anyone.
* Additonally, a person with AB- blood can receive blood from a donor with B- or A- blood.
* Additonally, a person with A+ blood can receive blood from a donor with O+ or A- blood.
* Additonally, a person with B+ blood can receive blood from a donor with O+ or B- blood.
* No other combination of donor and recipient blood types is compatible.
For this question, we will use symbols to represent each blood type. The symbol will match the types described above. So for example, the O+ blood type will be represented by the symbol 'O+. All symbols in the question will be one of the blood types described above.
Write a function compatible-litres in Racket that consumes a list of symbols, blood-bank, and a symbol, blood-type. Each element in blood-bank represents a 0.5 litre donation of the matching blood type symbol, and blood-type represents the blood type of a blood transfusion recipient. The function produces the total number of litres available for donation for someone with the given blood-type given the donations in blood-bank.
For example:
1
2
3
4
5
6
> (compatible-litres (list 'O- 'O+ 'O- 'B- 'AB-) 'AB-)
2
> (compatible -litres (list 'A+ 'B+) 'A-) 0
> (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+)
1.5
> (compatible-litres (list 'O- 'O+ 'O- 'B- 'AB-) 'AB-)
2
> (compatible-litres (list 'A+ 'B+) 'A-)
0
> (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+)
1.5
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education