Lecture overview -- Keyboard shortcut: 'u'  Previous page: Example streams -- Keyboard shortcut: 'p'  Next page: Applications of The sieve of Eratosthenes -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 5 - Page 25 : 26
Functional Programming in Scheme
The Order of Evaluation
Stream example: The sieve of Eratosthenes

The Sieve of Eratosthenes is a more sophisticated example of the use of streams

(define (sieve stream)
   (cons-stream
     (head stream)
     (sieve 
       (filter-stream
         (lambda (x) (not (divisible? x (head stream))))
         (tail stream)))))

The sieve stream function.

An illustration of the generation of prime numbers in The Sieve of Eratosthenes