Reputation: 2711
Racket provides a built-in function to reverse lists which is called reverse
. This function uses the fact that lists (at least proper lists) have an end which is null
(empty list).
On the other hand, streams by definition do not have an end. Actually, streams is a data structure created exactly to model infinite data.
Hence, there is not such a way to build a stream-reverse function.
Is the argumentation above enough to answer the question? Did I miss something?
It looks too informal for me.
Thanks in advance.
Upvotes: 1
Views: 94
Reputation: 48775
While you can make infinite streams not all streams need to be infinite. Eg. (stream 1 2 3 4)
will make a stream with delayed execution of the 4 elements and it is reversible.
You can make a stream-reverse
, but it will not work for infinite lists just like reverse
and sort
doesn't work for circular lists, just proper lists.
Upvotes: 1