KNOW:
BE ABLE TO:
cons
, append
, and list
Sample Exam Question:
Consider the following data definition of a binary tree used in a medical database:
(define-struct person (name bloodtype father mother)) ;; A BinaryTree is one of ;; false ;; (make-person String String BinaryTree BinaryTree) ;; interp: ;; name is the person's name ;; bloodtype is the person's blood type ;; (a person's bloodtype is one of "A", "B", "AB", or "O") ;; father and mother are the left and right subtreesWrite a function count-type that consumes a bloodtype and a binary tree and produces the number of people in the tree who have the given bloodtype.
;; count-type: String BinaryTree -> Natural ;; consumes a bloodtype and a binary tree and produces the number of people ;; in the tree with that bloodtype