A count-pairs starter kit
(define (cp pair)
(let ((visited '()))
(define (visited? pair vl)
; return #t if the pair is in vl, #f otherwise
; the member function is NOT useful for this because it does
; not check to see if the pair being searched is the exact
; same memory location as a pair in the list
; note that we need the second input to receive visited
; so we can cdr through its contents
; #t is used as a placeholder for real code
#t)
(define (cp2 pair)
; if not a pair, 0
; if already visited, 0
; else:
; updated visited (use set!) to include pair
; set! is not a placeholder--it is real code!
(set! visited (cons pair visited))
; recursive calls on car and cdr
; 0 is used as a placeholder for real code
0)
(cp2 pair)))