Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use dr racket to finish the function. Many Thanks! (@problem 1) ;; Problem 1 ;; Perhaps you want to plan some reading for Reading

Please use dr racket to finish the function. Many Thanks!

(@problem 1)

;; Problem 1 ;; Perhaps you want to plan some reading for Reading Break! Imagine ;; that you'd like to develop a program that produces a list of book titles, ;; in a specific order based on certain criteria. ;; ;; Design a function that consumes: ;; - a minimum rating ;; - a genre ;; - a ListOfBook ;; ;; and produces the titles of books that have a rating greater or ;; equal to the minumum, and that match the genre. The names ;; must be sorted in publication order (newest first). ;; ;; Your function must be called select-books. It must be designed ;; as a composition of three other functions called book-titles, ;; sort-books, and filter-books - in that order in the body ;; of select-books. ;; ;; Be sure to follow all applicable helper and other design rules. ;; ;; You must use these data definitions, with these names.

(@htdd Book) (define-struct book (title auth year genre rating)) ;; Book is (make-book String String Natural String Number) ;; interp. a book with its title, author, publication year, genre, and rating ;; (out of five, 1 is the lowest and 5 is the highest)

(define B1 (make-book "The Hate U Give" "Angie Thomas" 2017 "Young Adult" 4.3)) (define B2 (make-book "An Anonymous Girl" " Greer Hendricks, Sarah Pekkanen" 2019 "Suspense" 4.1)) (define B3 (make-book "Oh, the Places You'll go!" "Dr. Suess" 1990 "Children's" 4.4)) (define B4 (make-book "The English Patient" "Michael Ondaatje" 1992 "Historical Fiction" 3.9)) (define B5 (make-book "Quidditch Through the Ages" "Kennilworthy Whisp" 2001 "Fantasy" 3.8)) (define B6 (make-book "A Christmas Carol" "Charles Dickens" 1843 "Classics" 4.5)) (define B7 (make-book "Black Beauty" "Anna Sewell" 1877 "Classics" 3.9)) (define B8 (make-book "Arctic Dreams and Nightmares" "Alootook Ipellie" 1993 "Short Stories" 4.1)) (define B9 (make-book "The Bonesetter's Daughter" "Amy Tan" 2003 "Historical Fiction" 4.2)) (define B10 (make-book "Alias Grace" "Margaret Atwood" 1996 "Historical Fiction" 4))

(@dd-template-rules compound) ;4 fields

(define (fn-for-book b) (... (book-title b) (book-auth b) (book-year b) (book-genre b) (book-rating b)))

(@htdd ListOfBook) ;; ListOfBook is one of: ;; - empty ;; - (cons Book ListOfBook) ;; interp. a list of books

(define LOB0 empty) (define LOB1 (cons B1 empty)) (define LOB2 (cons B2 LOB1)) (define LOB3 (cons B3 LOB2)) (define LOB4 (cons B4 LOB3)) (define LOB5 (cons B5 LOB4)) (define LOB6 (cons B6 LOB5)) (define LOB7 (cons B7 LOB6)) (define LOB8 (cons B8 LOB7)) (define LOB9 (cons B9 LOB8)) (define LOB10 (cons B10 LOB9))

(@dd-template-rules one-of atomic-distinct compound ref self-ref)

(define (fn-for-lob lob) (cond [(empty? lob) (...)] [else (... (fn-for-book (first lob)) (fn-for-lob (rest lob)))]))

(@htdd ListOfString) ;; ListOfString is one of: ;; - empty ;; - (cons String ListOfString) ;; interp. a list of strings

(define LOS0 empty) (define LOS1 (cons "bat" LOS0)) (define LOS2 (cons "cat" LOS1))

(@dd-template-rules one-of atomic-distinct compound self-ref)

(define (fn-for-los los) (cond [(empty? los) (...)] [else (... (first los) (fn-for-los (rest los)))]))

;; === Functions ====

(@htdf select-books) (@signature Number String ListOfBook -> ListOfString)

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

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions