blob: b3ba946c9cf5da08ed3ec65c47d6c63cb77317fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
(use-modules (srfi srfi-41))
(define base (stream-from 2))
(define (curry f)
(lambda (x)
(lambda (y)
(f x y))))
(define-stream (sub-merge x y)
(if (eq? (stream-car x) (stream-car y))
(sub-merge (stream-cdr x) (stream-cdr y))
(stream-cons (stream-car x) (sub-merge (stream-cdr x) y))))
(define-stream (sieve input)
(stream-cons
(stream-car input)
(sieve (sub-merge (stream-cdr input)
(stream-map ((curry *) (stream-car input)) input)))))
(define euler (sieve base))
|