chunkBy array at compile time
Andrey
saasecondbox at yandex.ru
Wed Dec 19 08:20:50 UTC 2018
Hi,
I have got this code:
> import std.array : array;
> import std.algorithm.mutation;
> import std.algorithm.iteration;
> import std.stdio;
>
> void main()
> {
> string input = "sieviaghp";
> enum data = ["emo", "emoze", "emow", "emuo", "evuo", "ete",
> "ie", "vuo", "sie", "w"];
>
> enum index = 3;
> enum filtered = data.filter!(value => value.length >
> index).array();
> pragma(msg, filtered);
>
> enum GetSeq = filtered.chunkBy!((first, second) =>
> first[index] == second[index]);//.array();
> pragma(msg, GetSeq);
> }
There is an array of strings. I filter it using length of each
element. Result should be:
> ["emoze", "emow", "emuo", "evuo"]
Then I want to chuck it using symbol at position 'index' to get
this:
> ["emoze"] // group 1, symbol 'z'
> ["emow"] // group 2, symbol 'w'
> ["emuo", "evuo"] // group 1, symbol 'o'
Everything I'm doing at COMPILE time!
But when I try to build program I get this strange error:
>/dlang/dmd/linux/bin64/../../src/druntime/import/core/memory.d(827): Error: `fakePureErrno` cannot be interpreted at compile time, because it has no available source code
>onlineapp.d(15): compile time context created here
So, what is wrong here and how to chunkBy at compile time?
More information about the Digitalmars-d-learn
mailing list