Scheme 向Racket中的结构添加数据定义

Scheme 向Racket中的结构添加数据定义,scheme,racket,Scheme,Racket,如何将数据定义添加到这些中?目前,这一切给我的是“(例如;;动物是……) 首先定义结构: (define-struct animal (name species age breakfast-hour dinner-hour)) (define-struct attendant (name a1 a2 a3)) (define attendant1 (make-attendant "Dave" 'gorillas 'bats 'mandrills )) (define attendant2 (

如何将数据定义添加到这些中?目前,这一切给我的是“(例如;;动物是……)

首先定义结构:

(define-struct animal (name species age breakfast-hour dinner-hour))  
(define-struct attendant (name a1 a2 a3))
(define attendant1 (make-attendant "Dave" 'gorillas 'bats 'mandrills ))
(define attendant2 (make-attendant "John" 'crocodiles 'ocelots 'capybara ))                                  
(define attendant3 (make-attendant "Joe" 'pottos 'tapirs 'vultures ))
然后,动物(因为您需要在将它们分配给服务员之前创建它们):

最后,创建服务员,给每个男孩或女孩相应的动物:

(define gorilla (make-animal "Koko" "Gorilla" 4 8 10))
(define bat (make-animal "Bruce" "Bat" 1 23 5))
(define mandrill (make-animal "Manny" "Mandrill" 5 8 10))
(define crocodile (make-animal "Swampy" "Crocodile" 1 10 18))
(define ocelot (make-animal "Ozzy" "Ocelot" 7 7 17))
(define capybara (make-animal "Capy" "Capybara" 4 6 18))
(define potto (make-animal "Spot" "Potto" 2 2 6))
(define tapir (make-animal "Stripey" "Tapir" 3 10 17))
(define vulture (make-animal "Beaky" "Vulture" 10 9 19))

请注意,为了创建服务员,我们必须引用之前定义的动物之一。

首先定义结构:

(define-struct animal (name species age breakfast-hour dinner-hour))  
(define-struct attendant (name a1 a2 a3))
(define attendant1 (make-attendant "Dave" 'gorillas 'bats 'mandrills ))
(define attendant2 (make-attendant "John" 'crocodiles 'ocelots 'capybara ))                                  
(define attendant3 (make-attendant "Joe" 'pottos 'tapirs 'vultures ))
然后,动物(因为您需要在将它们分配给服务员之前创建它们):

最后,创建服务员,给每个男孩或女孩相应的动物:

(define gorilla (make-animal "Koko" "Gorilla" 4 8 10))
(define bat (make-animal "Bruce" "Bat" 1 23 5))
(define mandrill (make-animal "Manny" "Mandrill" 5 8 10))
(define crocodile (make-animal "Swampy" "Crocodile" 1 10 18))
(define ocelot (make-animal "Ozzy" "Ocelot" 7 7 17))
(define capybara (make-animal "Capy" "Capybara" 4 6 18))
(define potto (make-animal "Spot" "Potto" 2 2 6))
(define tapir (make-animal "Stripey" "Tapir" 3 10 17))
(define vulture (make-animal "Beaky" "Vulture" 10 9 19))
请注意,为了创建服务员,我们必须引用前面定义的动物之一