{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


CS61A_fa05_mt2 - Question 1(6 points What will Scheme print...

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

View Full Document Right Arrow Icon
Question 1 (6 points): What will Scheme print in response to the following expressions? If an expression produces an error message, you may just write "error"; you don't have to provide the exact text of the message. Also, draw a box and pointer diagram for the value produced by each expression. (map caddr '((2 3 5) (7 11 13) (17 19))) (list (cons 2 (cons 3 5))) (append (list '(2) '(3)) (cons '(4) '(5)))
Background image of page 1

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

View Full Document Right Arrow Icon
Question 2 (7 points) Suppose you are in a team working on a social networking program. You are given the constructor of a "person" data structure. (define (make-person first-name last-name favorite-sport favorite-movie) (list (list first-name last-name) favorite-sport (cons 'movie-favorite-movie))) a) Write the selectors: (define (first-name person)) (define (last-name person)) (define (favorite-movie person)) (define (favorite-sport person)) b) Your partner wrote a procedure find-partners that takes a person p and a list of persons lst as arguments, and returns the persons in the list that have the same favorite sport as p. Fix all the data abstraction violations in his code.
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.

{[ snackBarMessage ]}