Blob
1 (define (cycle? x)2 (let ((aux '()))3 (define (find-cycle z)4 (cond ((null? z) false)5 ((memq z aux) true)6 (else7 (set-cdr! (last-pair aux) (list z))8 (find-cycle (cdr z)))))9 (if (not (pair? x))10 (error "argument of cycle? must be a pair."))11 (set! aux (list x))12 (find-cycle (cdr x))))