How to easily construct objects with multi-param constructors from lazy ranges?

Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 6 01:00:12 PDT 2014


> Yea, but that won't work for forward ranges. It only provides opIndex if the
> underlying range provides it. Since the chunk size is a runtime parameter it
> can't implement opIndex efficiently for non-random access ranges.

But in your case, your range is random-access, no?

Or else, you can always map array on the chunks...

>
> staticChunks was a bit of a misnomer. staticTake would be a better name. The
> range would contains a static array and pops that number of elements from
> the input range. Then, opIndex can easily be defined.

What about takeExactly?


More information about the Digitalmars-d-learn mailing list