Lecture overview -- Keyboard shortcut: 'u'  Previous page: Examples of delayed evaluation -- Keyboard shortcut: 'p'  Next page: Example streams -- 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 23 : 26
Functional Programming in Scheme
The Order of Evaluation
Infinite lists in Scheme: Streams

We can work with lists of infinite length by delaying the evaluation of every list tail using delay

As an invariant, every list tail will be delayed

(cons-stream a b)   ~   (cons a (delay b))

(define head car)

(define (tail stream) (force (cdr stream)))


(define empty-stream? null?)

(define the-empty-stream '())

Stream primitives. Notice the way head is defined to be an alias of car.

y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/includes/stream.scmAn implementation of cons-stream in R5RS Scheme.


The functions mentioned above stem from the book Structure and Interpretation of Computer Programs