CSC 8310 Lisp Quiz
Villanova University, Spring 2001
David Matuszek
     Section 2

      Name ____________________________________________

 

Evaluate each of the following-- 3 points each
Please put your answer in the blank to the left of the expression

Assume:  P = '(X)
 Q = '((A) B C)
  1. _________________________ (QUOTE (X (Y)))

  2. _________________________ (QUOTE P)

  3. _________________________ (CAR P)

  4. _________________________ (CAR Q)

  5. _________________________ (CDR P)

  6. _________________________ (CDR Q)

  7. _________________________ (CONS Q ( ))

  8. _________________________ (CONS ( ) Q)

  9. _________________________ (EQ (( )) NIL)

  10. _________________________ (EQ ( ) '( ))

  11. _________________________ (ATOM (QUOTE (( ))))

  12. _________________________ (LIST P)

  13. _________________________ (LIST P Q)

  14. _________________________ (LIST '((A B)))

  15. _________________________ (LIST (QUOTE A) (QUOTE (A)))

  16. _________________________ (EQUAL P (QUOTE (X)))

  17. _________________________ (APPEND P Q)

  18. _________________________ (APPEND P NIL)

  19. _________________________ (NULL '(( )))

  20. _________________________ (COND ((CDR Q) P) ((CAR Q) Q) (T NIL) )

 

 

21. (10 points) Given the following function definition:

(defun befog (A L)
  (cond
     ((null L) ( ))
     ((null (car L)) (befog A (cdr L)))
     (t (cons A (befog A (cdr L)))) ) )
    what is the result of the following function calls?
    ___________________________________  (befog 'a '(a s i a) )

      
    ___________________________________  (befog 'b '(a nil b) )

 

Short answer questions
Fill in the blanks.

  1. (12 points) List the four rules given in the lectures for writing a recursive program.
    1. ______________________________________

    2. ______________________________________

    3. ______________________________________

    4. ______________________________________


  2. (8 points) In Java, the declaration Person p binds ____________________ to ____________________, while the statement p = new Person() binds ____________________ to ____________________.

  3. (5 points) If a programming language supports recursion, then when does it bind variables to storage locations? ______________________________ .

  4. (5 points) QUOTE, COND, and DEFUN are not functions, because their formal parameters are not bound to values at the time of call. The Lisp name for these things that look like functions, but are not actually functions, is ______________________________ .

 

Survey -- just for my own information
This does not count toward your grade.

Did you attempt the online Lisp quiz?

Did you successfully complete the online Lisp quiz?

If not, did you have problems with the program?

Do you think that the online quiz is, in general, a good idea?