CS200: Computer Science, Spring 2004
|
Notes: Wednesday 25 February 2004
Schedule
- Friday, 5 March: Problem Set 5
- Before 15 March: Read rest of GEB part I (Chapters 2-4 and 6-9, in addition to Chapters 1 and 5 you have already read).
Notes Mutation Procedures:
- (set! Name Expression) evaluate Expression and replace the value associated with Name with the value of Expression
- (set-car! Expression0 Expression1) evaluate Expression0 and Expression1 and store the value of Expression1 in the car part of the value of Expression0. Expression0 must evaluate to a cons pair.
- (set-cdr! Expression0 Expression1) evaluate Expression0 and Expression1 and store the value of Expression1 in the cdr part of the value of Expression0. Expression0 must evaluate to a cons pair.
(define (map! f lst) (if (null? lst) (void) (begin (set-car! lst (f (car lst))) (map! f (cdr lst)))))Why is mutation scary?
Why is mutation useful?
Why do our substitution evaluation rules fail when we allow mutation?
Would it be possible to create a circular list without using set-cdr!?
cs200-staff@cs.virginia.edu Using these Materials |