CS 1410-20 Lab 5

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.

  1. Implement the function count-white, which takes a list-of-toast and returns the number of toasts in the list with the kind 'white.

  2. 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?)

  3. 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.

  4. 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, 2011
mflatt@cs.utah.edu