cyclic structures
puzzle
complete
(define x …)
so that
(car x) ==> 1
(car (cdr x)) ==> 1
(car (cdr (cdr x))) ==> 1
(car (cdr (cdr (cdr x)))) ==> 1
… , forever
and (eq? x (cdr x)) ==> #t
solution
code
(define x(let ((c (cons 1 nil))) (set-cdr! c c) c))
property
(eq? c (cdr c)) ==> #t
Previous slide
Next slide
Back to first slide
View graphic version