CS61A_sp07_mt2

CS61A_sp07_mt2 - CS 61A Spring 2007 Midterm 2 Harvey...

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

View Full Document Right Arrow Icon
CS 61A, Spring 2007, Midterm 2, Harvey 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 car ‘((cons 1 2) (list 3 4))) (let (( x (list 1 2)) (y (list 7 8))) (cons x (list y x))) (list (append ‘(a b) ‘(c)) (cons ‘(a b) ‘(c)))
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 (5 points): We’re going to represent a date as simply a list of three numbers (define (make-date year month day) (list year month day)) (a) Write selectors for year, month, and date. Given a date, they should return the appropriate value. (define (year date) ___________________________) (define (month date) ___________________________) (define (day date) ___________________________) (b) Now, we’re going to use those dates to represent events. An event has a start date, an end date, and a description in the form of a sentence. Given the following selectors for an event, write a constructor for an event.
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 ]}

Page1 / 7

CS61A_sp07_mt2 - CS 61A Spring 2007 Midterm 2 Harvey...

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