Exercise 4.74

Read Exercise 4.74 ~ Solution

a) simple-flatten‘s argument is a stream whose elements are either the empty stream or a singleton stream. We need to filter out elements that are the empty stream and then take the first element of each resulting stream.

(define (simple-flatten stream)
  (stream-map stream-car
              (stream-filter (λ (s)
                               (not (stream-null? s)))

b) There is no difference in behaviour (as long as Alyssa’s assertions are correct.)


3 thoughts on “Exercise 4.74

  1. Thanks for all your solutions. More than the solutions, I liked reading your experience while working through the more difficult problems. Reading your experience kept me motivated. Thank you.

  2. Thanks, I feel guilty that I stopped before finishing all the book exercises. I need to carve out some time to complete them.

  3. I also took a long break and restarted it this year. It took me quite a good time to come into context. Hoping to close it this time. Wish you will also get time to complete the remaining chapter.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s