(define-struct boa (name length food)) ;; a Boa is a (make-boa String Natural String) ;; interpretation: represents a boa constrictor where ;; name is the boa's name ;; length is its length (in inches) ;; food is the boa's favorite food ;; examples (define MOLLY (make-boa "Molly" 21 "grapes")) (define HOMER (make-boa "Homer" 35 "donuts")) ;; selectors ;; boa-name: Boa -> String ;; consumes a boa and produces the boa's name ;; boa-length: Boa -> Natural ;; boa-food: Boa -> String ;; constructor ;; make-boa: String Natural String -> Boa ;; predicate ;; boa?: anything -> Boolean ;; boa-fit-cage?: Boa Natural -> Boolean ;; consumes a boa and the length of a cage and produces true if the length of ;; the boa is less than the length of the cage (produces false otherwise) (define (boa-fit-cage? a-boa cage-length) (< (boa-length a-boa) cage-length)) ;; test (check-expect (boa-fit-cage? MOLLY 30) true) (check-expect (boa-fit-cage? MOLLY 21) false) (check-expect (boa-fit-cage? (make-boa "Jack" 17 "popcorn") 10) false)