A slice consisting of non-consecutive elements of an array?
forkit
forkit at gmail.com
Thu Jan 13 19:52:27 UTC 2022
On Wednesday, 12 January 2022 at 06:16:49 UTC, vit wrote:
>
> Yes std.algorithm : filter.
>
> ```d
> import std.stdio : writeln;
> import std.algorithm : filter;
>
> void main()@safe{
> auto a = ["one", "one", "two", "one", "two", "one",
> "one", "two"];
>
> writeln(a);
> writeln(a.filter!(x => x == "one"));
> }
> ```
Any idea on how I can get a ptr (without hardcoding C style)
e.g. something like this:
immutable(string)*[] pointers = strings.filter!(x => x ==
"one").to!pointers.array;
More information about the Digitalmars-d-learn
mailing list