The cash registers at the
Rice Epicurean Market talk to you. A register's controller receives a
number greater than 0
and then builds a list with the following
five elements:
'dollar
if the dollar amount is 1
and 'dollars
otherwise;
'and
'cent
if the cent amount is 1
and 'cents
otherwise.
103
and the result is
(cons 1 (cons 'dollar (cons 'and (cons 3 (cons 'cents empty)))))
You are to define the controller as a Scheme program. You may use our solution to Problem 2 of the first homework set.
Hints: Recall that Scheme provides the functions quotient
and remainder
.
Develop the program lookup
. The program takes an symbol,
which is called the search-key, and a table. It returns the first
pair whose key is equal to the search-key. If it can't find such an
pair, it returns false.
Note: Schemers often call such a table an A-list, short for
association list.
A MnM is either
|