Blob


1 ;; Devise a correct version of the count-pairs procedure of exercise 3.16 that returns the number of distinct pairs in any structure. (Hint: Traverse the structure, maintaining an auxiliary data structure that is used to keep track of which pairs have already been counted.)
3 (define (test-case actual expected)
4 (newline)
5 (display "Actual: ")
6 (display actual)
7 (newline)
8 (display "Expected: ")
9 (display expected)
10 (newline))
12 (define (count-pairs x)
13 (if (not (pair? x))
14 0
15 (+ (count-pairs (car x))
16 (count-pairs (cdr x))
17 1)))
19 (define three '(a b c))
20 (define four )
21 (define seven )
22 (define circular )