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'  Help page about these notes  Alphabetic index  Course home  Lecture 4 - Page 25 : 27
Programming Paradigms
Evaluation Order and Infinite Lists
Stream example: The Sieve of Eratosthenes

The Sieve of Eratosthenes is a slightly 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