This table shows the number of electoral votes allocated to several states:
| Washington | 11 |
| Oregon | 7 |
| Iowa | 7 |
| California | 54 |
| Florida | 25 |
Define a Scheme variable named electoral-votes to encode
this table. Represent the table by a list of sublists, one for each
state, where the car of each sublist is the name of the
state and the cdr of each sublist is a list whose only
element is the number of electoral votes for that state.
(define electoral-votes
'((Washington 11) (Oregon 7) (Iowa 7) (California 54)
(Florida 25)))
This tree represents the geographic relation of some states, counties and cities in the USA:
+------------------ USA -------------+
| |
+----- Washington -----+ Florida
| | |
+----- King ----+ +- Thurston -+ +- Dade -+
| | | | | |
Seattle Bellevue Olympia Lacey Miami Hialeah
Define a Scheme variable named usa-tree to encode this
tree. Represent the tree as a list whose car is
USA and whose cdr is a list of subtrees, one
for each of the two states. Continue filling in subtrees until you
reach the cities. At each level, the car of the subtree
holds the data and the cdr of the subtree is a list of subtrees.
At each city, the cdr of the sublist is the empty list to indicate
that there are no more subtrees.
(define usa-tree
'(USA
(Washington
(King (Seattle) (Bellevue))
(Thurston (Olympia) (Lacey)))
(Florida
(Dade (Miami) (Hialeah)))))