CISC-280 Program Development Techniques
Homework 4: More Fun with Lists and Trees
Due: Thursday, October 9, 2008
1. (12 points) Read exercise 2.20, page 104, and use those ideas to
write a function called not-equal-first. not-equal-first takes 1
or more integers and returns a list containing all of the original
integers that are not equal to the first one. E.g.,
(not-equal-first 1 2 1 3 1 4 1 5) returns (2 3 4 5). You may find
the function eq? helpful. This function takes two expressions and
returns #t if they are the same -- i.e., if they are the same symbol or
made up of the same list cells.
2. (10 points) Exercise 2.22, page 107, fixing square-list.3. (10 points) Exercise 2.23, page 107, for-each.
4. (15 points) Exercise 2.30, page 112, square-tree.
5. (15 points) (typer s-exp)
-- write a function typer that takes an arbitrarily complex
s-expression and returns a new one with the same ``shape'' but with
only symbols NUMBER and SYMBOL corresponding to the type of the
original atoms in the list.
Examples:
> (typer '(a b 3 d))
(SYMBOL SYMBOL NUMBER SYMBOL)
> (typer '((a 2.3) (((b c)) 3)))
((SYMBOL NUMBER) (((SYMBOL SYMBOL)) NUMBER))