Question

Scheme Language: Define a function nondecreastream, which takes in a stream of numbers and outputs a...

Scheme Language: Define a function nondecreastream, which takes in a stream of numbers and outputs a stream of lists, which overall has the same numbers in the same order, but grouped into segments that are non-decreasing.

For example, if the input is a stream containing elements 1 2 3 4 1 2 3 4 1 1 1 2 1 1 0 4 3 2 1 ...

the output should contain elements (1 2 3 4) (1 2 3 4) (1 1 1 2) (1 1) (0 4) (3) (2) (1) ...

If the input is an infinite stream, the output should be an infinite stream and if the input is finite, the output should also be finite.

Hint: avoid any direct recursive calls outside the context of a second part of a call to cons-stream, otherwise your solution won't work for infinite streams!

(define (nondecreastream s)

'YOUR-CODE-HERE)

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Scheme Language: Define a function nondecreastream, which takes in a stream of numbers and outputs a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT