CS212
Exams
Spring
1999 -
Final
(defclass <container> () (contents :type <list> :accessor contents :initarg :contents :initvalue '())) (defclass <contained> () (location :type <container> :accessor location :initarg :location))
Using the above class definitions and the following method, show that it is possible for a container object to be contained in itself.
(defgeneric (place-in (obj <contained>) (c <container>))) (defmethod (place-in (obj <contained>) (c <container>)) (set! (contents c) (cons obj (contents c))) (set! (location obj) c))