- intset? now does what it should
This commit is contained in:
parent
ae6bdcbf88
commit
49fa6ec239
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
;;; Functions on bounds.
|
;;; Functions on bounds.
|
||||||
|
|
||||||
|
(define (b? thing) (or (number? thing) (b-max? thing)))
|
||||||
|
|
||||||
(define (b-max? bound) (eq? bound 'max))
|
(define (b-max? bound) (eq? bound 'max))
|
||||||
|
|
||||||
(define (b< b1 b2)
|
(define (b< b1 b2)
|
||||||
|
@ -59,6 +61,13 @@
|
||||||
(define i-beg car)
|
(define i-beg car)
|
||||||
(define i-end cdr)
|
(define i-end cdr)
|
||||||
|
|
||||||
|
(define (i? thing)
|
||||||
|
(and (pair? thing)
|
||||||
|
(let ((b1 (car thing)) (b2 (cdr thing)))
|
||||||
|
(and (b? b1)
|
||||||
|
(b? b2)
|
||||||
|
(b<= b1 b2)))))
|
||||||
|
|
||||||
;; Beware: the following syntax leads to multiple evaluations of each
|
;; Beware: the following syntax leads to multiple evaluations of each
|
||||||
;; interval expression!
|
;; interval expression!
|
||||||
(define-syntax let-int
|
(define-syntax let-int
|
||||||
|
@ -108,14 +117,12 @@
|
||||||
;;; Functions on sets (lists of individual intervals).
|
;;; Functions on sets (lists of individual intervals).
|
||||||
|
|
||||||
(define (intset? thing)
|
(define (intset? thing)
|
||||||
;; TODO check that intervals are disjoint and increasing
|
(and (proper-list? thing)
|
||||||
(and (list? thing)
|
(pairwise (lambda (i1 i2)
|
||||||
(every (lambda (pair)
|
(and (i? i1) (i? i2)
|
||||||
(and (pair? pair)
|
(not (i-contiguous? i1 i2))
|
||||||
(number? (car pair))
|
(i< i1 i2)))
|
||||||
(or (number? (cdr pair)) (b-max? (cdr pair)))
|
thing)))
|
||||||
(b< (car pair) (cdr pair))))
|
|
||||||
thing)))
|
|
||||||
|
|
||||||
(define (intset-union s1 s2)
|
(define (intset-union s1 s2)
|
||||||
(cond ((null? s1) s2)
|
(cond ((null? s1) s2)
|
||||||
|
|
Loading…
Reference in New Issue