我正在尝试制作该功能
author-book
给定一本书,产生这本书的作者。这是我为此创建的数据-
(define-struct audiobook ( title author length-in-minutes voice-person))
(define-struct ebook ( title author size-in-kolobytes symbol ))
(define-struct hardcover (title author number-of-pages genre ))
(define audiobook1 (make-audiobook "The Hunger Games" "Suzanne Collins" "50 minutes" "David Larrson"))
(define audiobook2 (make-audiobook "Catching Fire" "Suzanne Collins" "55 minutes" "David Larrson"))
(define audiobook3 (make-audiobook "Mockingjay" "Suzanne Collins" "40 minutes" "David Larrson"))
(define ebook1 (make-ebook "Divergent" "Veronica Roth" "100000kbs" 'Kindle))
(define ebook2 (make-ebook "Dracula" "Bram Stocker " "134000kbs" 'Ebook))
(define ebook3 (make-ebook "Jane Eyre" "Charlotte Brontë " "400000kbs" 'IPad))
(define hardcover1 (make-hardcover "Pursued" "Jud White" "100000kbs" "Crime"))
(define hardcover2 (make-hardcover "Private Berlin" "James Patterson" "100000kbs" "Suspense"))
(define hardcover3 (make-hardcover "Francona" "Terry Francona" "100000kbs" "Sports"))
我试过了
(define (author-of-book n)
(audiobook-author n))
这给了我只有有声读物的作者。有没有办法让我不用编写三个单独的函数就可以得到其余部分的作者?(就像电子书作者...)