University of Washington • CSE583 • D. Notkin
©
2000
33
Side-effects
l
There are several special forms that allow
side-effects (note the
!
convention)
–
set! set-car! set-cdr!
l
set!
rebinds a variable to a new value
l
(define (test x)
(set! x (cons 1 x))
x)
(test ‘(2 3))
®
(1 2 3)