Blob


1 (define (cycle? x)
2 (define (compare end-index current-index z current-list)
3 (cond ((eq? end-index current-index) false)
4 ((eq? current-list z) true)
5 (else (compare end-index
6 (+ 1 current-index)
7 z
8 (cdr current-list)))))
9 (define (find-cycle z i)
10 (cond ((null? z) false)
11 ((compare i 0 z x) true)
12 (else (find-cycle (cdr z) (+ 1 i)))))
13 (if (not (pair? x))
14 (error "Argument of cycle? must be a pair")
15 (find cycle (cdr x) 1)))