; Determines whether a list has a cycle (define (has-cycle? x) (define (iter fast-ptr slow-ptr) (cond ((null? fast-ptr) #f) ((null? (cdr fast-ptr)) #f) ((eq? fast-ptr slow-ptr) #t) (else (iter (cddr fast-ptr) (cdr slow-ptr))))) (if (null? x) #f (iter x (cdr x))))