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 lst-1 (cons 'b unique1*))
(define lst-2 (cons 'a (rest lst-1)))
(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 Saturday, 11 August 2018, at 22:52 hours.