Question: Define a pure, recursive function stream-zip that takes two arguments, each of which is a stream, and produces a stream of pairs, where the
Define a pure, recursive function stream-zip that takes two arguments, each of which is a stream, and produces a stream of pairs, where the nth pair's car is the nth element of xs and the nth pair's cdr is the nth element of ys. If xs and ys do not have the same length, then stream-zip should return a stream that has as many elements as the "shortest" of xs and ys. That is, if stream-zip runs out of items in either xs or ys, it can stop producing pairs. The behavior of stream-zip is undefined if either xs or ys is not a stream. Note that stream-zip is like zip from Homework 1, but it operates on streams. Unlike zip, we cannot assume that the two streams have the same length. The stream-zip function must also potentially handle infinite streams-there is no guarantee that xs and ys are finite streams.
Step by Step Solution
3.40 Rating (144 Votes )
There are 3 Steps involved in it
The streamzip function is a pure recursive function that takes two streams as arguments and produces ... View full answer
Get step-by-step solutions from verified subject matter experts
