www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - mir.ndslice : multi dimensional associative array - Example/Docs

reply Vino <akashvino79 gmail.com> writes:
Hi All,

   Is it possible to create a multi dimensional associative array 
using mir.ndslice,
   if yes,
    (1): request you to point me to some example / docs
    (2): below is an example multi dimensional associative array 
using the core d module, and
         how can we to implement the same using mir.ndslice.
    (3): What are the pros and cons of using mir.ndslice over the 
core d module.

import std.stdio;
void main () {
    string[int][string] aa;
    aa["Name"] = [1: "test01", 2:"test02"];
    aa["Pool"] = [1: "Development", 2:"Quality"];
    foreach(i; aa["Pool"].byValue) { writeln(i); }	
}

From,
Vino.B
Oct 26 2020
parent reply 9il <ilyayaroshenko gmail.com> writes:
On Monday, 26 October 2020 at 14:31:00 UTC, Vino wrote:
 Hi All,

   Is it possible to create a multi dimensional associative 
 array using mir.ndslice,
   if yes,
    (1): request you to point me to some example / docs
    (2): below is an example multi dimensional associative array 
 using the core d module, and
         how can we to implement the same using mir.ndslice.
    (3): What are the pros and cons of using mir.ndslice over 
 the core d module.

 import std.stdio;
 void main () {
    string[int][string] aa;
    aa["Name"] = [1: "test01", 2:"test02"];
    aa["Pool"] = [1: "Development", 2:"Quality"];
    foreach(i; aa["Pool"].byValue) { writeln(i); }	
 }

 From,
 Vino.B
No. ndslice provides rectangular arrays. An associative array (as it defined in D) can't be really 2D, instead, it is an AA of AAs like in your example. A real 2D analog associative arrays are DataFrames. It is a postponed WIP ndslice feature. Ilya
Oct 26 2020
parent Vino <akashvino79 gmail.com> writes:
On Tuesday, 27 October 2020 at 02:50:55 UTC, 9il wrote:
 On Monday, 26 October 2020 at 14:31:00 UTC, Vino wrote:
 [...]
No. ndslice provides rectangular arrays. An associative array (as it defined in D) can't be really 2D, instead, it is an AA of AAs like in your example. A real 2D analog associative arrays are DataFrames. It is a postponed WIP ndslice feature. Ilya
Hi Ilya, Thank you very much.
Oct 28 2020