Lecture overview -- Keyboard shortcut: 'u'  Previous page: Stream example: The sieve of Eratosthenes -- Keyboard shortcut: 'p'    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 26 : 26
Functional Programming in Scheme
The Order of Evaluation
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.

y:/Kurt/Files/courses/prog3/prog3-03/sources/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!