[Issue 13936] groupBy must be redone

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jan 12 13:24:18 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13936

--- Comment #30 from Andrei Alexandrescu <andrei at erdani.com> ---
(In reply to hsteoh from comment #27)
> Anyway, another design occurred to me. For ranges with slicing, we could
> scan Groups in advance and just return slices from .front. The predicate
> only needs to be evaluated once per element pair. This can be extended to
> non-sliceable ranges by precomputing the length of each Group in advance:
> then Group.popFront won't need to evaluate the predicate again (just
> decrement the length), whereas now if you iterate over 10 copies of each
> Group, each one will have to evaluate the predicate each time.

I think that's a slightly worse design. Lazy is as lazy does.

--


More information about the Digitalmars-d-bugs mailing list