The goals of this assignment are to refresh your skills with Scheme, and to serve as a diagnostic. Most of the subsequent assignments in this course will require a solid foundation in Scheme programming, such as is required to complete the problems below. If you have trouble with this assignment, you will likely have trouble in the rest of the course as well.
Implement a simple Scheme program to count the number of atoms
in an arbitrary Scheme expression. An atom is anything which does not
satisfy the
Provide a data definition for representing words of
arbitrary length with lists. A letter
is represented with the
symbols 'a
through 'z
plus '_
.
Develop the function reveal-list
. It consumes three arguments:
the chosen word, which is the word that we have to guess;
the status word, which states how much of the word we have guessed so far; and
a letter, which is our current guess.
It produces a new status word, that is, a word that contains
ordinary letters and '_
. The fields in the new status word are
determined by comparing the guess with each pair of letters from the status
word and the chosen word:
If the guess is equal to the letter in the chosen word, the guess is the corresponding letter in the new status word.
Otherwise, the new letter is the corresponding letter from the status word.
Test the function with the following examples:
(reveal-list (list 't 'e 'a) (list '_ 'e '_) 'u)
(reveal-list (list 'a 'l 'e) (list 'a '_ '_) 'e)
(reveal-list (list 'a 'l 'l) (list '_ '_ '_) 'l)
First determine what the result should be.