Computer Science Name
-
LISP worksheet #4
Do the following exercises. Evaluate the final expression. Be sure to enclose answers that are lists in parentheses and to write answers that are individual atoms without parentheses.
1.
(SETQ b (ADD 6 8))
(MULT b 2)
2.
(SETQ a (REVERSE '(3 6 9)))
(CAR (CDR a)))
3.
(SUB (SUB 10 5) (MULT 2 2))
4.
(SETQ g (SUB (MULT 5 3) (SUB 6 1)))
(MULT g 6)
5.
(SETQ careful '(MULT 6 2 4))
(CAR (CDR (REVERSE careful)))
6.
(MULT (SUB 6 4) (SUB (MULT 8 2) 12))
7.
(SUB (CAR (CDR '(8 7 6 2 1 9))) (SUB 12 9))
8.
(SETQ A (ADD (MULT 2 4) 3 (SUB 6 9)))
(SETQ B (ADD (MULT A 2) 9))
(MULT B 3)
9.
(SETQ x '(A B C D))
(CDR (REVERSE x))
10.
(CDR (CDR (CDR '(1 2 3 4 5))))