Allow (list?) to work on circular lists

This commit is contained in:
Justin Ethier 2015-03-25 22:24:29 -04:00
parent f23b89a05f
commit 59e895be19

View file

@ -84,12 +84,16 @@
end
(func (car lst) (foldr func end (cdr lst)))))
(define (not x) (if x #f #t))
(define (list? obj)
(cond
((null? obj) #t)
((pair? obj)
(list? (cdr obj)))
(else #f)))
(define (list? o)
(define (_list? obj)
(cond
((null? obj) #t)
((pair? obj)
(_list? (cdr obj)))
(else #f)))
(if (Cyc-has-cycle? o)
#t
(_list? o)))
(define (zero? n) (= n 0))
(define (positive? n) (> n 0))
(define (negative? n) (< n 0))