Lab Quiz Solutions, Foundations of Computing, Week 6 -- Thurs Nov 2 2000

For all questions, assume the following definitions have been executed:

(define s '(a b c d)) 
(define l '((a b) c d))  ;; That's the letter l (small L), not the numeral 1 (one)

Write down the value of each of these expressions:

  1. s
    (a b c d)

  2. (car s)
    a

  3. (cdr s)
    (b c d)

  4. (cons 'a '(b c d))
    (a b c d)

  5. (cons (car s) (cdr s))
    (a b c d)

  6. (car (cdr s))
    b

  7. (cadr s)
    b

  8. l ;; That's the letter l (small L), not the numeral 1 (one)
    ((a b) c d)

  9. (car l)
    (a b)

  10. (cdr l)
    (c d)

  11. (cons '(a b) '(c d))
    ((a b) c d)

  12. (cons (car l) (cdr l))
    ((a b) c d)

  13. (list '(a b) '(c d))
    ((a b) (c d))

  14. (append '(a b) '(c d))
    (a b c d)