1 665c255d 2023-08-04 jrmu ;; 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 665c255d 2023-08-04 jrmu (define (test-case actual expected)
5 665c255d 2023-08-04 jrmu (display "Actual: ")
6 665c255d 2023-08-04 jrmu (display actual)
8 665c255d 2023-08-04 jrmu (display "Expected: ")
9 665c255d 2023-08-04 jrmu (display expected)
12 665c255d 2023-08-04 jrmu (define (count-pairs x)
13 665c255d 2023-08-04 jrmu (if (not (pair? x))
15 665c255d 2023-08-04 jrmu (+ (count-pairs (car x))
16 665c255d 2023-08-04 jrmu (count-pairs (cdr x))
19 665c255d 2023-08-04 jrmu (define three '(a b c))
20 665c255d 2023-08-04 jrmu (define four )
21 665c255d 2023-08-04 jrmu (define seven )
22 665c255d 2023-08-04 jrmu (define circular )