123456789101112131415161718192021222324252627282930 |
- (add-to-load-path (dirname (current-filename)))
- (define-module (math)
- #:export (number-range-inclusive
- number-range
- number-range-exclusive))
- (define (number-range-inclusive a b)
- (define (iter low high)
- (cond [(> high low)
- (cons low
- (iter (+ low 1) high))]
- [else (list high)]))
- (cond [(< a b) (iter a b)]
- [(< b a) (iter b a)]
- [else '()]))
- (define (number-range a b)
- (define (iter low high)
- (cond [(> high low)
- (cons low
- (iter (+ low 1) high))]
- [else '()]))
- (cond [(< a b) (iter a b)]
- [(< b a) (iter b a)]
- [else '()]))
- (define (number-range-exclusive a b)
- (cdr (number-range a b)))
|