Bug 8555 – Round Robin and Infinite Ranges

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-15T14:58:00Z
Last change time
2015-06-09T05:15:19Z
Assigned to
nobody
Creator
daniel350

Comments

Comment #0 by daniel350 — 2012-08-15T14:58:29Z
http://dlang.org/phobos/std_range.html#roundRobin As would be expected, RoundRobin goes into an infinite loop if the range is infinite; perhaps !isInfinite!R would be suitable to test against the input ranges? This may benefit other exhausting range functions also.
Comment #1 by peter.alexander.au — 2013-01-01T14:12:27Z
It's not a good idea to constrain the function unnecessarily. For example, you might want to construct an infinite round robin, but then take a finite number of elements from the start. e.g. auto r = roundRobin(cycle([0, 1]), cycle([0, 1, 2])).take(10); This should work, even though cycle is infinite. There's nothing wrong with infinite ranges, as long as you don't try to iterate them in their entirety :-)
Comment #2 by justin — 2014-06-06T18:19:37Z
roundRobin appears to work as documented, and accepting infinite ranges is a valid use case, as explained by Peter Alexander.