CS 15-212: Fundamental Structures of Computer Science II

Lecture 17: Streams and Memoization

We continue with streams from the last lecture, and complete our implementation by introducing a memoizing delay function. Memoization ensures that a suspended expression is evaluated at most once. When a suspension is forced for the first time, its value is stored in a reference cell and simply returned when the suspension is forced again. The implementation that we present makes a subtle and elegant use of a "self-modifying" code technique with circular references.

Key Concepts

Sample Code

On-line Notes

[ home | schedule | language | assignments | handouts ]

John Lafferty