(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))