learning-sicp

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

exercise-18.scm (492B)


      1 (define-library (sicp tests chapter-3 exercise-18)
      2   (import (scheme base))
      3   (import (srfi :1))
      4   (import (srfi :64))
      5   (import (only (sicp solutions chapter-3 exercise-18) cyclic?))
      6 
      7   (begin
      8     (test-begin "chapter-3-exercise-18")
      9 
     10     (define a (list 1 2 3))
     11 
     12     (define b
     13       (let ([a (list 1 2 3)])
     14         (set-cdr! (last-pair a) a)
     15         a))
     16 
     17     (test-equal
     18         #f
     19       (cyclic? a))
     20 
     21     (test-equal
     22         #t
     23       (cyclic? b))
     24 
     25     (test-end "chapter-3-exercise-18")))