lab6 - CS 61A Week 6 solutions LAB EXERCISES: 2.25. Extract...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 CS 61AWeek 6 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 (quote foo) no matter what foo is, and no matter what the context is. So ''foo is an abbreviation for (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.

Page1 / 6

lab6 - CS 61A Week 6 solutions LAB EXERCISES: 2.25. Extract...

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