drkcore

2007/08/22 21:25:13

SICP 3.13

リストの問題

(define (make-cycle x)
  (set-cdr! (last-pair x) x)
  x)

という定義に対し

gosh> (define z (make-cycle (list 'a 'b 'c)))
z
gosh> z
#0=(a b c . #0#)

これに(last-pair z)は無限ループ

Comments