lab5 - CS 61A LAB EXERCISES: 2.25. Extract 7 Week 5...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 61A Week 5 solutions LAB EXERCISES: 2.25. Extract 7 (cadr (caddr '(1 3 (5 7) 9))) I did that one by knowing that "cadr" means "the second element" and "caddr" means "the third element," and the seven is the second element of the third element of the overall list. (car (car '((7))) (cadr (cadr (cadr (cadr (cadr (cadr '(1 (2 (3 (4 (5 (6 7)))))))))))) 2.53. Finger exercises. Note that it matters how many parentheses are printed! > (list 'a 'b 'c) (a b c) > (list (list 'george)) ((george)) > (cdr '((x1 x2) (y1 y2))) ((y1 y2)) > (cadr '((x1 x2) (y1 y2))) (y1 y2) > (pair? (car '(a short list))) #f > (memq 'red '((red shoes) (blue socks))) #f > (memq 'red '(red shoes blue socks)) (red shoes blue socks) 2.55 (car ''abracadabra) When you write 'foo it's just an abbreviation for (quote foo) no matter what foo is, and no matter what the context is. So ''foo is an abbreviation for
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
(quote (quote foo)) If you enter the expression (car ''abracadabra) you are really saying (car (quote (quote abracadabra)))
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/12/2010 for the course CS 61A taught by Professor Harvey during the Spring '08 term at University of California, Berkeley.

Page1 / 3

lab5 - CS 61A LAB EXERCISES: 2.25. Extract 7 Week 5...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online