[an error occurred while processing this directive]
cs150: Notes 18
Assignments Due
Notes
Assignment Expression: (set! Name
Expression)
Evaluate Expression and replace the value associated with Name
with the value of Expression.
Pair mutators:
- (set-car! 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.
- (set-cdr! 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.
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!?
(define (map! f lst)
(if (null? lst) (void)
(begin
(set-car! lst (f (car lst)))
(map! f (cdr lst)))))
[an error occurred while processing this directive]