Re: Sort Associative Array by Key

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
foo.byPair .array .sort!((a, b) => a.key < b.key) .map!(a => a.value); Is it possible to specify in `map` to return the result `[a.key] = a.value`? To make the result look like `[key:[val], key:[val]]`

Re: ImportC "no include path set"

2023-02-08 Thread Elfstone via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 14:08:47 UTC, bachmeier wrote: On Wednesday, 8 February 2023 at 06:49:06 UTC, Elfstone wrote: I believe all three versions (2017,2019,2022) of my VS are up to date, and I have working C/C++ projects on them. But you encouraged me to give a few more tries, and I

Re: staticMap but with two arguments

2023-02-08 Thread John Chapman via Digitalmars-d-learn
On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote: I adapted staticMap's implementation to two sets of arguments: So I've got this implementation, but wonder if I can generalise the arg splitting portion rather than write it manually for each N? ```d template staticMapN(size_t N

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 19:04:15 UTC, Alexander Zhirov wrote: [...] I would write a data structure and use struct members to reason about things, but that's probably just preference. ``` import std; struct DatabaseEntry { int id = -1; string deleted; string name; t

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 19:32:22 UTC, Ali Çehreli wrote: This should do it: [...] Yes, it works! I'll try it tomorrow on a large array of data. Thank you very much! This turns out to be a simple loop with a comparison of the existence of a key (whether it is included in an array or n

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Ali Çehreli via Digitalmars-d-learn
On 2/8/23 11:04, Alexander Zhirov wrote: > That is, the result is arrays of table B that are missing OR not equal > to arrays in table A. This should do it: alias MyType = string[string][int]; // 'a' is subtracted from 'b' MyType difference(MyType b, MyType a) { MyType result; foreach

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 18:57:00 UTC, Anonymouse wrote: Can you explain how you determine how/if two entries are different? I apologize. I have not written, in fact, what I need to get. Array `A` ```d [ 4:["id":"4", "deleted":"f", "name":"6.2"], 3:["id":"3", "deleted":"f", "n

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 17:55:03 UTC, Alexander Zhirov wrote: Not an easy task for me, maybe you can advise your compact solution. There are two associative arrays of type `string[string][int]`. It is necessary to find the differences and return them when comparing: Can you explain h

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 18:08:40 UTC, Ali Çehreli wrote: Just because this sounds complicated, I hope the data structure can be designed differently to be more friendly to this operation. (?) Ali This is the result of an SQL query. Roughly speaking, I need to compare the result of

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Ali Çehreli via Digitalmars-d-learn
On 2/8/23 09:55, Alexander Zhirov wrote: > the differences Is it considered a difference if a key exists but the value is different? Or is that an error case if you encounter that? > return them when comparing: The representation seems difficult as well. When given this: > 6:["id":"6",

Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
Not an easy task for me, maybe you can advise your compact solution. There are two associative arrays of type `string[string][int]`. It is necessary to find the differences and return them when comparing: ```d [ 6:["id":"6", "deleted":"f", "name":"6.2_test"], 5:["id":"5", "deleted":"f"

Re: ImportC "no include path set"

2023-02-08 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 06:49:06 UTC, Elfstone wrote: I believe all three versions (2017,2019,2022) of my VS are up to date, and I have working C/C++ projects on them. But you encouraged me to give a few more tries, and I found out I had been using ..bin64/dmd.exe. Running ..bin/dmd.ex

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread zjh via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 12:12:57 UTC, thebluepandabear wrote: but I still think the language has potential in the future I don't know if they have a sense of crisis. Now `D` in tiebo ranks `50`.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread zjh via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 12:07:35 UTC, zjh wrote: they are always unwilling to add facilities useful to others, `D`'s community is small, this is the reason!

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 12:10:59 UTC, zjh wrote: On Wednesday, 8 February 2023 at 12:07:35 UTC, zjh wrote: they are always unwilling to add facilities useful to others, `D`'s community is small, this is the reason! yeah, I've already switched to Java because of this. but I still t

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread zjh via Digitalmars-d-learn
On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear wrote: Hi, In Java/C# you can create purely static classes. ... Last time, someone proposed to add `private` like `C++'s`, and then it was the same,they are always unwilling to add facilities useful to others, and then he left `D

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread GrimMaple via Digitalmars-d-learn
On Monday, 23 January 2023 at 01:28:30 UTC, Ali Çehreli wrote: I agree with Adam here. The language should provide solutions and the programmer should pick appropriate ones. Then just add `static class`, as it will provide a solution without robbing you of another solution. You still can put

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread thebluepandabear via Digitalmars-d-learn
C# just makes it 'easy' for the programmer to define it as such, without all the nonsense other languages require. In addition, the C# compiler WILL prevent nonsense code, which is exactly what I want from a compiler ;-) Java as well.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 09:00:40 UTC, thebluepandabear wrote: C# just makes it 'easy' for the programmer to define it as such, without all the nonsense other languages require. In addition, the C# compiler WILL prevent nonsense code, which is exactly what I want from a compiler ;-) J