
Fall 2008 LISP Written Assignment #1 CMSC 420
Hanan Samet
In order to do the following exercises assume:
•The expression x+yis represented as (PLUS x y). The expression xy+x+3 is represented
as (PLUS (TIMES x y) x 3)
•The list ((A B) (B A C D) (C B D E) (D B C E) (E C D F) (F E)) is used to rep-
resent the following graph according to a scheme whereby there is a sublist for each vertex
consisting of the vertex itself followed by the vertices to which it is connected.
A
C
F
EB
D
1. If we represent sums and products as indicated above and use (MINUS X),(QUOTIENT X Y),
and (POWER X Y) as representations of −x,x/y, and xyrespectively, then
(a) What do the lists
(QUOTIENT 2 (POWER (PLUS X (MINUS Y)) 3))
and
(PLUS -2 (MINUS 2) (TIMES X (POWER Y 3.3)))
represent?
(b) How are the expressions xyz+3(u+v)−3and (xy−yx)/(xy+yx)to be represented?
2. In the above mentioned graph notation, what graph is represented by the list
((A D E F) (B D E F) (C D E F) (D A B C) (E A B C) (F A B C))?
3. Write the list (PLUS (TIMES X Y) X 3) as an s-expression. This is sometimes referred to
as “dot-notation.”
4. Write the following s-expressions in list notation to whatever extent is possible:
(a) (A . NIL)
(b) (A . B)
(c) ((A . NIL) . B)
(d) ((A . B) . ((C . D) . NIL))
1