mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 04:25:06 +02:00
Allow (list?) to work on circular lists
This commit is contained in:
parent
f23b89a05f
commit
59e895be19
1 changed files with 10 additions and 6 deletions
16
trans.scm
16
trans.scm
|
@ -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)
|
||||||
(cond
|
(define (_list? obj)
|
||||||
((null? obj) #t)
|
(cond
|
||||||
((pair? obj)
|
((null? obj) #t)
|
||||||
(list? (cdr obj)))
|
((pair? obj)
|
||||||
(else #f)))
|
(_list? (cdr obj)))
|
||||||
|
(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))
|
||||||
|
|
Loading…
Add table
Reference in a new issue