Material to Understand

Exercises

  1. Draw a picture of how Common Lisp would represent '(1 (2 3) ((4 5) 6)).
  2. Draw a picture of how Common Lisp would represent '(defun add-one ( n ) (+ n 1)).
  3. Describe one advantage of Lisp representing data and code in the same manner.
  4. Draw a picture showing the effects of the following.
       (setf list1 '(2 3))
       (setf list2 (cons 1 list1))
    
  5. Draw a picture showing the effects of the following.
       (setf list1 '(1 2))
       (setf list2 '(3))
       (setf list3 (append list1 list2))
    
  6. Explain why it is preferable to use cons over append.
  7. Why is it dangerous to do the following:
       (setf alist '(1 2 3))
       (setf (second alist) 4)
    
  8. Why is eq more efficient than equal?