learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-18.scm (410B)


      1 (define-library (sicp solutions chapter-3 exercise-18)
      2   (import (scheme base))
      3   (export cyclic?)
      4 
      5   (begin
      6     (define (cyclic? l)
      7       (define (cyclic?' l known-pairs)
      8         (cond
      9          ((null? l) #f)
     10          ((pair? l)
     11           (if (memq l known-pairs)
     12               #t
     13               (cyclic?' (cdr l)
     14                         (cons l known-pairs))))
     15          (else #f)))
     16 
     17       (cyclic?' l '()))))