exercise-19.scm (451B)
1 (define-library (sicp solutions chapter-3 exercise-19) 2 (import (scheme base)) 3 (export cyclic?) 4 5 (begin 6 (define (cyclic? l) 7 8 (define (cyclic?' tortoise hare) 9 (cond 10 ((or (null? hare) 11 (null? (cdr hare))) 12 #f) 13 ((eq? tortoise hare) #t) 14 (else 15 (cyclic?' (cdr tortoise) 16 (cddr hare))))) 17 18 (if (null? l) 19 #f 20 (cyclic?' l (cdr l))))))