Splitting a sequence using a binary predicate on adjacent elements
Andrea Fontana
nospam at example.com
Wed Oct 18 07:27:29 UTC 2017
On Wednesday, 18 October 2017 at 07:26:20 UTC, Nordlöw wrote:
> On Wednesday, 18 October 2017 at 07:01:19 UTC, Andrea Fontana
> wrote:
>> If you try to use your data with chunkBy!"a != b+1", it does
>> not work, as expected.
>
> What's the motivation behind this limitation?
>
> Without it
>
> chunkBy!"a + 1 == b"
>
> is exactly what I want.
Probably it's an implementation problem. On source code you read:
// Issue 13595
version(none) // This requires support for non-equivalence
relations
@system unittest
{
import std.algorithm.comparison : equal;
auto r = [1, 2, 3, 4, 5, 6, 7, 8, 9].chunkBy!((x, y) =>
((x*y) % 3) == 0);
assert(r.equal!equal([
[1],
[2, 3, 4],
[5, 6, 7],
[8, 9]
]));
}
And other.
More information about the Digitalmars-d-learn
mailing list