Combining infinite ranges

Simen kjaeraas simen.kjaras at gmail.com
Tue Jun 1 07:23:36 PDT 2010


Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:

>> All forward ranges should be doable, too.
>
> How would the spanning strategy work for two forward infinite ranges?

In a complex, horrible way?

0. Save initial states (position = 0)
1. Pop first until past the position of the other
2. Restore other
3. Pop other until past the position of the first
4. Restore first
6. Goto 1.

Screw that, as you cannot save positions. Well, I guess a long should
be enough for most, but it might not be. As long as there is no way
to compare positions, 'tis unpossible.

If we accept saving the position (the number of pops), this approach
should be applicable to any number of ranges.

--
Simen


More information about the Digitalmars-d mailing list