Bug 17966 – chunkBy cannot accept an input range (from multiwayMerge)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2017-11-05T13:20:13Z
Last change time
2019-01-30T06:37:23Z
Assigned to
No Owner
Creator
Matthew Gamble
Comments
Comment #0 by gamblemj — 2017-11-05T13:20:13Z
I posted this issue to forum.dlang.org/learn https://forum.dlang.org/post/[email protected]
I was asked to post this here by Nicholas Wilson, who responded to my post on "learn". This is my first post here, apologies I did it wrong.
I guess there are two issues one of which seems to be a bug.
The bug: chunkBy is advertised as working on input ranges, but it seems that it doesn't.
The smaller issue: Why can't multiwayMerge produce a forward range instead of input range?
auto d =[2,4,6,8];
auto e =[1,2,3,5,7];
auto f =[d,e];
writeln(f.multiwayMerge.chunkBy!"a == b");//error happens
writeln(f.multiwayMerge.array.chunkBy!"a == b");//no error, but there must be a better way!
I know the test code seems silly. Why not just use multiwayUnion and no need for chunkBy? However, this is a dumbed down version to show the error. There are use cases where "a == b" is a bit more complicated and the underlying elements are not completely equivalent and so you want them all grouped together, in which case multiwayUnion is not going to do the right thing.
OK, hope I did this right.
Matt
Comment #1 by github-bugzilla — 2017-11-20T17:25:31Z