exercise-19.scm (873B)
1 (define-library (sicp tests chapter-3 exercise-19) 2 (import (scheme base)) 3 (import (srfi :1)) 4 (import (srfi :64)) 5 (import (only (sicp solutions chapter-3 exercise-19) cyclic?)) 6 7 (begin 8 (test-begin "chapter-3-exercise-19") 9 10 (define (make-cyclic lst) 11 (set-cdr! (last-pair lst) lst) 12 lst) 13 14 (test-equal 15 #f 16 (cyclic? '())) 17 18 (test-equal 19 #f 20 (cyclic? '(1))) 21 22 (test-equal 23 #f 24 (cyclic? '(1 2))) 25 26 (test-equal 27 #f 28 (cyclic? '(1 2 3))) 29 30 (test-equal 31 #t 32 (cyclic? 33 (make-cyclic (list 1)))) 34 35 (test-equal 36 #t 37 (cyclic? 38 (make-cyclic (list 1 2)))) 39 40 (test-equal 41 #t 42 (cyclic? 43 (make-cyclic (list 1 2 3)))) 44 45 (test-equal 46 #t 47 (cyclic? 48 (make-cyclic (list 1 2 3 4)))) 49 50 (test-end "chapter-3-exercise-19")))