ps09 - CS51 Assignment 9: Mutability and OOP Due: Tuesday,...

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

View Full Document Right Arrow Icon
CS51 Assignment 9: Mutability and OOP Due: Tuesday, April 28th, 2009, 11:59PM Total Points: 48 (including 5 style points) (Note: There will be an optional contest to use CS51 techniques or algorithms to pre- dict the outcomes of Red Sox games. The details will be finalized this weekend. Check http://cs51.seas.harvard.edu/redsox.php for updates.) 1 Mutable Data (18 points total) 1.1 Lists Exercise 1. 12 points We’ve defined the mutable lists foo and bar as follows: ( define foo ( mcons a ( mcons b ( mcons c empty ) ) ) ) ( define bar ( mcdr foo ) ) Fill in the values of foo and bar after applying the following functions. Assume that before each function is run, the variables are reset to the above values. NOTE: while you can obviously test your answers in DrScheme, you should first try to figure them out yourself–you won’t have DrScheme available on the final. (a) [2 points] > ( define ( f1 lst ) ( set-mcar ! ( mcdr lst ) x ) ) > ( f1 foo ) (b) [2 points] > ( f1 bar ) (c) [2 points] > ( define ( f2 ) ( set-mcar ! ( mcdr foo ) x ) ) > ( f2 ) 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
1 MUTABLE DATA CS51 Assignment 9: Mutability and OOP (d) [2 points] > ( define ( f3 lst ) ( let ( [ copy lst ] ) ( set-mcar ! ( mcdr copy ) x ) ) ) > ( f3 bar ) (e)
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 / 4

ps09 - CS51 Assignment 9: Mutability and OOP Due: Tuesday,...

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