summaryrefslogtreecommitdiff
path: root/sieve/sundaram.scm
diff options
context:
space:
mode:
Diffstat (limited to 'sieve/sundaram.scm')
-rw-r--r--sieve/sundaram.scm16
1 files changed, 8 insertions, 8 deletions
diff --git a/sieve/sundaram.scm b/sieve/sundaram.scm
index 457efb8..384bc3d 100644
--- a/sieve/sundaram.scm
+++ b/sieve/sundaram.scm
@@ -19,9 +19,9 @@
(define-stream (stream-ordered-diff xstrm ystrm)
(stream-match xstrm (() '()) ((x . xs)
(stream-match ystrm (() xstrm) ((y . ys)
- (if (eq? x y)
- (stream-ordered-diff xs ys)
- (stream-cons x (stream-ordered-diff xs ystrm))))))))
+ (cond ((< x y) (stream-cons x (stream-ordered-diff xs ystrm)))
+ ((> x y) (stream-ordered-diff xstrm ys))
+ (else (stream-ordered-diff xs ys))))))))
@@ -30,7 +30,7 @@
(stream-match ystrm (() xstrm) ((y . ys)
(cond ((< x y) (stream-cons x (stream-merge xs ystrm)))
((> x y) (stream-cons y (stream-merge xstrm ys)))
- ((eq? x y) (stream-cons x (stream-merge xs ys)))))))))
+ (else (stream-cons x (stream-merge xs ys)))))))))
@@ -48,11 +48,11 @@
(define ij-stream
(stream-let loop ((n 1) (strm (i-stream 1)))
- (let* ((cutoff ((curry >) (stream-car (i-stream n))))
- (next (+ n 1))
+ (let* ((next (+ n 1))
+ (cutoff ((curry >) (stream-car (i-stream next))))
(available (stream-take-while cutoff strm))
- (remainder (stream-drop-while cutoff strm)))
- (stream-append available (loop next (stream-merge remainder (i-stream next)))))))
+ (remaining (stream-drop-while cutoff strm)))
+ (stream-append available (loop next (stream-merge remaining (i-stream next)))))))