Lecture 7 : Mixed Data ;; an animal is one of ;; - boa ;; - dillo ;; - tiger has-name?: have students do after put up examples (has-name? (make-boa "toothy" 25 "lettuce") "fred") "expects" false (has-name? (make-boa "toothy" 25 "lettuce") "toothy") "expects" true (has-name? (make-dillo 25 true) "fred") "expects" false ;; has-name? : animal string -> boolean ;; determine whether given animal has given name (false if unnamed) [drive template and recipe here] ; animal-func : animal -> ? ; ? (define (animal-func an-ani) (cond [(boa? an-ani) ... (boa-name an-ani) ... (boa-length an-ani) ... (boa-food an-ani) ... ] [(dillo? an-ani) ... (dillo-length an-ani) ... (dillo-dead? an-ani) ...] [(tiger? an-ani) ... (tiger-name an-ani) ... (tiger-length an-ani) ... (tiger-sells an-ani) ...])) ; has-name?: animal string -> boolean ; consumes an animal and a name and determines if animal has given name (define (has-name? an-ani name) (cond [(boa? an-ani) (string=? name (boa-name an-ani))] [(dillo? an-ani) false] [(tiger? an-ani) (string=? name (tiger-name an-ani)) ]))