Re: Undefined reference to "S_ISDIR" and "S_ISREG" when compiling with "-betterC"

2022-01-13 Thread rempas via Digitalmars-d-learn

On Monday, 10 January 2022 at 21:17:22 UTC, Adam D Ruppe wrote:

It's not a system call, it just a bitflag tester.


I wasn't talking about the flag actually but for the "stat" 
system call


Re: A slice consisting of non-consecutive elements of an array?

2022-01-13 Thread forkit via Digitalmars-d-learn
On Thursday, 13 January 2022 at 20:32:40 UTC, Stanislav Blinov 
wrote:

On Thursday, 13 January 2022 at 19:52:27 UTC, forkit wrote:


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;


```d
import std.stdio : writeln;
import std.algorithm : filter, map, each;
import std.range : array;

void main() @safe
{
immutable strings = ["one", "one", "two", "one", "two", 
"one", "one", "two"];
immutable(string)*[] pointers = strings.filter!(x => x == 
"one").map!((ref x) @trusted => ).array;

pointers.each!(p => writeln(p - [0]));
}
```


just perfect! thanks.


Re: A slice consisting of non-consecutive elements of an array?

2022-01-13 Thread Stanislav Blinov via Digitalmars-d-learn

On Thursday, 13 January 2022 at 19:52:27 UTC, forkit wrote:


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;


```d
import std.stdio : writeln;
import std.algorithm : filter, map, each;
import std.range : array;

void main() @safe
{
immutable strings = ["one", "one", "two", "one", "two", 
"one", "one", "two"];
immutable(string)*[] pointers = strings.filter!(x => x == 
"one").map!((ref x) @trusted => ).array;

pointers.each!(p => writeln(p - [0]));
}
```


Re: A slice consisting of non-consecutive elements of an array?

2022-01-13 Thread forkit via Digitalmars-d-learn

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;