Blame


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