Lecture overview -- Keyboard shortcut: 'u'  Previous page: Stream example: The Sieve of Eratosthenes -- Keyboard shortcut: 'p'  Next page: Exercises -- 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 26 : 27
Programming Paradigms
Evaluation Order and Infinite Lists
Applications of The sieve of Eratosthenes

The sieve process produces the stream of all prime numbers

Expression

Value

(define primes 
  (sieve 
    (integers-starting-from 2)))

(stream-section 25 primes)
(2 3 5 7 11 13 17 19 23 29 31 37 41 
 43 47 53 59 61 67 71 73 79 83 89 97)

The first 25 prime numbers made by sieving a sufficiently long prefix of the integers starting from 2.

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/sieve.scmAll the functions necessary to use the Sieve of Eratosthenes.

In addition, however, you must load the Scheme stream stuff. The most remarkable function is filter-streams, which illustrates that it is necessary to rewrite all our classical higher order function to stream variants. This is clearly a drawback!