Re: Array operations

2025-05-03 Thread Nick Treleaven via Digitalmars-d-learn
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[]"? It appears not. `y` is already a slice `int[]`, so slicing it does not change the type. Slicing without indices selects all elem

Re: D equivalent for LINQ Where

2025-05-03 Thread Ali Çehreli via Digitalmars-d-learn
On 5/2/25 2:44 PM, Python wrote: > 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. Yes, understa

Re: Array operations

2025-05-03 Thread Andy Valencia via Digitalmars-d-learn
On Saturday, 3 May 2025 at 11:18:00 UTC, Nick Treleaven wrote: 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 stepped away from D's exception architecture? It throws a RangeErr

Re: Array operations

2025-05-03 Thread Kagamin via Digitalmars-d-learn
You link with release version of druntime, try to link with debug version.

Re: Array operations

2025-05-03 Thread Kagamin via Digitalmars-d-learn
But yeah, core.internal.util.array is wrong design, it should be boolean function, and the compiler should generate assert(areTypedArraysConformable()); at the caller side.

Re: Array operations

2025-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 3, 2025 8:23:00 AM Mountain Daylight Time Andy Valencia via Digitalmars-d-learn wrote: > At least on 1.40.1 of the ldc2 distro for x86-64, uses the > "illegal instruction" instruction. That sounds like an ldc bug then. With dmd, your program gives [2, 2, 2, 2, 1, 1, 1, 1] [2, 2,

Re: D equivalent for LINQ Where

2025-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 3, 2025 12:08:45 PM Mountain Daylight Time Ali Çehreli via Digitalmars-d-learn wrote: > On 5/2/25 2:44 PM, Python wrote: > > On Friday, 2 May 2025 at 14:33:57 UTC, Richard (Rikki) Andrew Cattermole > > wrote: > >> Have you tried filter? > >> > >> https://dlang.org/phobos/std_

Re: alias vs enum for lambdas?

2025-05-03 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 2 May 2025 at 16:53:05 UTC, monkyyy wrote: This is still a continuation of aliases are for types, enums for literals ```d alias F=(i)=>i+1; ```d pragma(msg, is(F)); // false, F is not a type ``` Even if we give `i` a type: ```d alias F=(int i)=>i+1; pragma(msg, is(F)); // still fa