(a) Write (delay ) as a special form for (lambda () ) and (force ), as discussed in class.
(b) Write (stream-cons x y) as a special form, as discussed in class.
(c) Write stream analogues of some familiar list processing functions, including:
(stream-ref str n) --- returns the nth
element in stream str
(stream-filter pred str) --- makes a new stream of
elements satisfying pred
(stream-for-each proc str) --- applies proc to each
element of str for side effect
(first n str) --- makes a stream of the
first n items in str
(list->stream lis) --- makes a stream from
(stream->list str) --- opposite coercion
For example, if you have defined a stream of even integers called evens, you can display the first 50 even integers as follows:
(stream-for-each (lambda (x) (display x)(display " ")) (first 50 evens)).
Test your functions convincingly!
(d) Now define a bunch of streams to test your functions:
(i) an infinite stream of 1's
(ii) an infinite stream of all even integers
(iii) an infinite stream of random numbers between 1 and 100
(iv) write a predicate (primefi n) that tests for primality and use it to create