首先定义结构:
(define-struct animal (name species age breakfast-hour dinner-hour))
(define-struct attendant (name a1 a2 a3))
然后,动物(因为您需要在将它们分配给服务员之前创建它们):
(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 attendant1 (make-attendant "Dave" gorilla bat mandrill))
(define attendant2 (make-attendant "John" crocodile ocelot capybara))
(define attendant3 (make-attendant "Joe" potto tapir vulture))
请注意,为了创建服务员,我们必须引用之前定义的动物之一。