CS 136 Tutorials - Spring 2007

CS 136 Home » Tutorials » Tutorial 2: Service Managers and Destructive Methods »

Solution for second semantics example

The part of the code marked in green is the part which is about to be expanded, and the part marked in red is the part which was just expanded.

Previous First Next
(define unique1* (cons 'c empty))
(define unique2* (cons 'b unique1*))
(define lst-1 unique2*)
(define lst-2 (cons 'a (rest unique2*)))
(set-rest! (rest lst-2) (cons 'd empty))
(set! lst-1 (cons 'a (cons 'd empty)))
(set-rest! lst-2 (rest (rest lst-2)))
(set-rest! lst-1 empty)

Last modified on Wednesday, 09 January 2019, at 14:31 hours.