CS200: Computer Science, Spring 2003

Notes: Monday 24 February 2003
Schedule
 Now: Exam 1 due
 Before 10 March: Read rest of GEB part I (Chapters 24 and 69, in addition to Chapters 1 and 5 you have already read).
 Friday, 14 March: Problem Set 5: Wahoo! Auctions
Notes Mutation Procedures:
 (set! Name Expression) — evaluate Expression and replace the value associated with Name with the value of Expression
 (setcar! Expression_{0} Expression_{1}) — evaluate Expression_{0} and Expression_{1} and store the value of Expression_{1} in the car part of the value of Expression_{0}. Expression_{0} must evaluate to a cons pair.
 (setcdr! Expression_{0} Expression_{1}) — evaluate Expression_{0} and Expression_{1} and store the value of Expression_{1} in the cdr part of the value of Expression_{0}. Expression_{0} must evaluate to a cons pair.
(define (adelphiaize! lst) (if (null? lst) (void) ; nothing to return (begin (if (< (car lst) 0) (setcar! lst 0)) (adelphiaize! (cdr lst)))))Why is mutation scary?
Why is mutation useful?
Why do our evaluation rules fail when we allow mutation?
Would it be possible to create a circular list without using setcdr!?

cs200staff@cs.virginia.edu Using these Materials 