blackboard nautilus actionselected

by Prof. Jazmyn Maggio PhD 4 min read

Delays and yields

We need two definitions to make streams work. First, delay is a macro that replaces a function with an anonymous function with it's body equal to the function. Later when we need to evaluate the function, we only have to call the anonymous function. This is what yield does. Yield isn't as necessary, but it makes it clear what's happening.

More general definitions

For more general streams it is simple to add a next method for each object.

Fibonacci list stream

Now to try it on the Fibonacci numbers. Instead of making each element the nth Fibonacci number we'll make it the list of the first n+1 Fibonacci numbers.