1 (define (test-case actual expected)
15 (define (make-cycle x)
16 (set-cdr! (last-pair x) x)
19 (define (count-pairs x)
22 (+ (count-pairs (car x))
26 (define three '(a b c))
27 (define a-pair (cons '() '()))
28 (define b-pair (cons a-pair a-pair))
29 (define four (cons 'a b-pair))
30 (define seven (cons b-pair b-pair))
31 (define circular (make-cycle '(a b c)))
33 (test-case (count-pairs three) 3)
34 (test-case (count-pairs four) 4)
35 (test-case (count-pairs seven) 7)
36 (test-case (count-pairs circular) 'infinite-loop)