I am trying to get some items from a list, but `find` gives me
unexpected results.
```
import std.stdio;
import std.algorithm;
int[] x = [1, 2, 3, 4, 5, 1, 2, 3];
void main()
{
auto selection = x.find!(a => a == 2);
foreach(item;selection)
{
writeln(item);
}
}
```
Out
Have you tried filter?
https://dlang.org/phobos/std_algorithm_iteration.html#.filter
Yes. But at the same time, defining a function via alias is a 1st
class function, unlike a standard function definition!
alias af = (int x) => x;
auto sf(int x) => x;
auto v = af;
auto p = &sf;
This means that the definitions are not equivalent.
In essence, an alias function behaves like a la
On Friday, 2 May 2025 at 14:33:57 UTC, Richard (Rikki) Andrew
Cattermole wrote:
Have you tried filter?
https://dlang.org/phobos/std_algorithm_iteration.html#.filter
Thx. Anyway, what find returns aftrr first occurrence is
unexpected.
On Friday, 2 May 2025 at 22:19:53 UTC, Andy Valencia wrote:
In the following code, two questions. First, is there any
difference between "x[] = y" and "x[] = y[]"?
With basic slices no; I could construct something with overloads
tho
```d
import std.stdio : writeln;
auto foo(ref int[] a, re
On Friday, 2 May 2025 at 14:32:04 UTC, Python wrote:
I am trying to get some items from a list, but `find` gives me
unexpected results.
```
import std.stdio;
import std.algorithm;
int[] x = [1, 2, 3, 4, 5, 1, 2, 3];
void main()
{
auto selection = x.find!(a => a == 2);
foreach(item;se
On Friday, 2 May 2025 at 13:55:46 UTC, Orion wrote:
Yes. But at the same time, defining a function via alias is a
1st class function, unlike a standard function definition!
alias af = (int x) => x;
auto sf(int x) => x;
auto v = af;
auto p = &sf;
This means that the definitions are not equival
In the following code, two questions. First, is there any
difference between "x[] = y" and "x[] = y[]"? It appears not.
Second, in assigning from arrays of differing sizes, Phobos
causes an illegal instruction, rather than the sort of exception
I'd have expected. I'm curious why they steppe