On Tuesday, 26 November 2019 at 05:17:54 UTC, Taylor R Hillegeist
wrote:
On Tuesday, 26 November 2019 at 05:05:48 UTC, Taylor R
Hillegeist wrote:
I'm attempting to do a segment group.
details:
alias ProbePoint[3]=triple;
triple[] irqSortedSet = UniqueTriples.keys
.sort!("a[1].irqid <
b[1].irqid",SwapStrategy.stable)
.array;
83:triple[][] irqSortedSets = irqSortedSet.chunkBy!((a,b) =>
a[1].irqid == b[1].irqid);
GetAllTriplesExtractFileIrqSplit.d(83): Error: cannot
implicitly convert expression `chunkBy(irqSortedSet)` of type
`ChunkByImpl!(__lambda4, ProbePoint[3][])` to
`ProbePoint[3][][]`
I have something that looks like a triple[][] but I can't seem
to get that type out.
when I add .array it converts to a Group which doesn't make
sense to me because I'm not using a unary comparison. Any
thought?
a simpler example:
import std.algorithm.comparison : equal;
import std.array;
// Grouping by particular attribute of each element:
uint[3][] data = [
[1, 1,0],
[1, 2,0],
[2, 2,0],
[2, 3,0]
];
uint[3][][] r1 = data.chunkBy!((a,b) => a[0] == b[0]);
fails in the same way.
What exactly is the problem, as this works for me if I understood
your goal correctly:
´´´
void main()
{
import std.algorithm.comparison : equal;
import std.array;
import std;
// Grouping by particular attribute of each element:
uint[3][] data = [
[1, 1,0],
[1, 2,0],
[2, 2,0],
[2, 3,0]
];
auto r1 = data.chunkBy!((a,b) => a[0] == b[0]);
}
´´´
If it is the type of the return value --> the return value of
chunkBy has a different one compared to the input. Instead, you
get an abstracted range whereas the input data serves as a source.