CISC-280 HW #6       Due October 30

You can find some code fragments for problem one in $CLASSHOME/hw6/hw6.scm or on the web link

1. Data-directed Programming Practice.

Develop two data structures, one to represent WINE and one to represent CHEESE.

Each wine has a NAME, PRICE, TYPE [one of  'red 'white], and SWEETNESS [one of 'dry 'semi-dry 'sweet].
Each cheese has a PRICE, NAME, and TYPE [one of 'mild 'sharp 'blue 'smoked]

Develop a data-directed package for each data type. PUT and GET have been implemented for you. Your external interface should look something like this:

;;; EXTERNAL INTERFACE
(define (price thing) (apply-generic 'price thing))
(define (name thing) (apply-generic 'name thing))
(define (type thing) (apply-generic 'type thing))
(define (sweetness thing) (apply-generic 'sweetness thing))
(define (compatible? thing1 thing2) (apply-generic 'compatible? thing1 thing2))
(define (make-cheese name price type) ((get 'make-food 'cheese) price name type))
(define (make-wine name price type sweetness) ((get 'make-food 'wine) name type price sweetness))

Develop a function print-list that takes a list of foods of different types and prints out the name and price of each.

Develop a function compatible? that tells if two foods are compatible. Two cheeses are always compatible. Two wines are compatible if thier sweetness levels are equal. A wine is compatible with a cheese if the wine is red and the cheese is blue, or if the wine is white and the cheese is mild. (Caution: don't actually follow these rules at your next wine-and-cheese-bash :-)

There will be some difficulty in getting compatible? to work properly with args of different types. First, make sure that you do as much work as possible within the individual packages. Secondly, discuss the difficulty you had in implementing compatible? with multiple types and what it might mean for very large software systems.

2. Practice with STATE.

Exercise 3.2 (from the textbook)

Exercise 3.3

Exercise 3.4

Exercise 3.7