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;

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

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;

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",

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

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",