A toast is defined as follows:
;; A toast is ;; (make-toast symbol number[0 to 10]) (define-struct toast (kind level))
where a toast’s kind can be any symbol, including (but not limited to) 'white or 'wheat.
Implement the function count-white, which takes a list-of-toast and returns the number of toasts in the list with the kind 'white.
Implement the function count-wheat, which takes a list-of-toast and returns the number of toasts in the list with the kind 'wheat.
(Aren’t you tempted to cut-and-paste count-white?)
Implement the function count-untoasted, which takes a list-of-toast and returns the number of toasts in the list at toast level 0.
Hopefully you abstracted over count-white and count-wheat, but now you will probably need to abstract further.
Implement the function count-yummy, which takes a list-of-toast and returns the number of toasts in the list that are yummy. Yummy toast is wheat toast at a level between 4 and 8 inclusive.
Last update: Wednesday, September 28th, 2011mflatt@cs.utah.edu |