Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
bartleby
Concept explainers
Question
Hi, I need to write this without using recursion. I am learning Dr. Racket, not phyton. I can use local definitions and lambda.
Transcribed Image Text: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: 0-, 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 0+ blood type will be represented by the symbol '0+. 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 > (compatible-litres (list '0- '0+ '0- 'B- 'AB-) 'AB-)
2 2
3 > (compatible-litres (list 'A+ 'B+) 'A-)
4 0
5 > (compatible-litres (list 'A+ 'B+ 'AB+) 'AB+)
6 1.5
Submit your solution in the file a08q1.rkt.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
Step by stepSolved in 2 steps
Knowledge Booster
Background pattern image
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.Similar questions
- writing a general-purpose sort method in Java, the sort method needs to compareobjects. There are two ways to give the sort method the code to compare objects,implementing the interfaces Comparable and Comparator respectively. Briefly, describe thetwo ways. Write excerpts of use examplesarrow_forwardGive an explanation of the differences between overloading and override methods.arrow_forwardThe code still does not seem to work for me. The error I get is: "Program stack overflow." I am using GNU Common Lisp Listener, perhaps this code can be tweaked again to ensure this error does not pop up again?arrow_forward
- 1) What is the difference between a list and a tuple? And when do we use them? 2) What is encapsulation? Why do we use it 3) What is a constructor in a class and how can we define it? 4) What are Overriding and Overloading 5) What are the differences between a list and a set? 6) What is the difference between the Python identity operator (is/is not) and the equality operator (==/!=)? Where to use them and where not? 7) What is the difference between OOP and Functional programming? 8) What are iterators, generators, and decorators in Pythonarrow_forwardUse java and correctly indent code.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education