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

      Name ____________________________________________

 

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

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

  2. _________________________ (QUOTE P)

  3. _________________________ (CAR P)

  4. _________________________ (CAR '((A B)))

  5. _________________________ (CDR P)

  6. _________________________ (CDR '((A B)))

  7. _________________________ (CONS Q ( ))

  8. _________________________ (CONS ( ) Q)

  9. _________________________ (EQ ( ) NIL)

  10. _________________________ (EQ Q Q)

  11. _________________________ (ATOM '(( )))

  12. _________________________ (LIST P)

  13. _________________________ (LIST P Q)

  14. _________________________ (LIST (QUOTE ((P Q))))

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

  16. _________________________ (EQUAL P '((A) B C))

  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 lat)
  (cond
     ((null lat) t)
     ((eq a (car lat)) nil)
     (t (befog a (cdr lat))) ) )
    what is the result of the following function calls?
    ___________________________________  (befog 'a '(a s i a) )

      
    ___________________________________  (befog 'b '((a b) c (d e)) )

 

Short answer questions -- 5 points each
Fill in the blanks.

  1. In Algol 60 and other languages that support recursion, space for local variables in functions is allocated where? ____________________ .

  2. When writing a recursive function, you should avoid changing the values of what kind of variables? (one answer is enough) ____________________ .

  3. The last of Matuszek's four rules for writing a recursive function is: ____________________.

  4. When does the C language bind function calls to their executable bodies?____________________ .

  5. When does the Java language bind method calls to their executable bodies? ______________________________ .

  6. The first test in a Lisp function is almost always a test for____________________ .

 

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?