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 end
(func (car lst) (foldr func end (cdr lst))))) (func (car lst) (foldr func end (cdr lst)))))
(define (not x) (if x #f #t)) (define (not x) (if x #f #t))
(define (list? obj) (define (list? o)
(define (_list? obj)
(cond (cond
((null? obj) #t) ((null? obj) #t)
((pair? obj) ((pair? obj)
(list? (cdr obj))) (_list? (cdr obj)))
(else #f))) (else #f)))
(if (Cyc-has-cycle? o)
#t
(_list? o)))
(define (zero? n) (= n 0)) (define (zero? n) (= n 0))
(define (positive? n) (> n 0)) (define (positive? n) (> n 0))
(define (negative? n) (< n 0)) (define (negative? n) (< n 0))