CIT 594 First Quiz
Spring 2002, Dave Matuszek
Name __________________________________________
  1. (5 points each) Tell what Lisp returns for each of the following (you don't need to quote your answers.)
    (CAR '(NIL)) NIL
    (CAR '((X) Y Z)) (X)
    (CDR '(()())) (NIL)
    (CDR (QUOTE ((NIL)))) NIL
    (CONS '(P) 'Q) ((P) . Q)
    (CONS 'A '((NIL))) (A (NIL))
    (CONS (QUOTE ((X))) (QUOTE Y)) (((X)) . Y)
    (EQ NIL ()) T
    (ATOM NIL) T
    (NULL (QUOTE A)) NIL
    (EQUAL '(()) '(NIL)) T
    (LIST '(P) '((X Y)) 'A) ((P) ((X Y)) A)
    (APPEND '((X Y)) '((X) Y)) ((X Y) (X) Y)
    (APPEND '(P Q R) '(())) (P Q R NIL)
    (COND ((NULL 'A) 'A) (T 'B) ) B
    (DEFUN DOUBLE (N) (+ N N) ) DOUBLE


  2. (8 points) State, briefly, the four rules for doing recursion.

    1. Do the base cases first
    2. Recur only with a simpler case
    3. Don't alter global variables
    4. Don't look down

  3. (5 points) Briefly, define the term refactoring.

    Rewriting and re-designing your program

  4. (2 points) One of these was mentioned in The Pragmatic Programmer--circle it.

               Making stone soup          Making an omlet          Raising the flag          Eating crow


  5. ( 5 points) Draw the structure, using cons cells, for the list ((A B) C).