Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #3536

Re: Generating multi-level associative arrays

From Victor Porton <porton@narod.ru>
Newsgroups comp.programming
Subject Re: Generating multi-level associative arrays
Followup-To comp.programming
Date 2013-06-23 18:06 +0300
Organization Aioe.org NNTP Server
Message-ID <kq72u1$jc4$1@speranza.aioe.org> (permalink)
References <kq4ps2$ds$1@speranza.aioe.org> <kq67tn$1k3$1@dont-email.me> <kq6ouc$mpp$1@speranza.aioe.org> <kq72c0$v1k$1@dont-email.me>

Followups directed to: comp.programming

Show all headers | View raw


Rui Maciel wrote:

> Victor Porton wrote:
> 
>> Rui Maciel wrote:
>> 
>>> Victor Porton wrote:
>>> 
>>>> But what is the best way to do this if we want a MULTILEVEL associative
>>>> array? (indexed by first key "a", then by key "b", etc.)
>>>> 
>>>> I want to discuss the most elegant, short, and practical solution for
>>>> this kind of problems.
>>> 
>>> I don't know if it's the most elegant, but if you wish to have multiple
>>> keys map to a value then you can resort to a tuple containing both keys
>>> as your map's key.
>>> 
>>> That approach is very common.  For example, with the "dictionary of
>>> keys" matrix data structure, the matrix elements are stored in a
>>> key:value pair whose key is a (row, column) tuple.
>> 
>> It seems you have misunderstood me. I ask about forming a *multilevel*
>> associative array like:
>> 
>> [1:[2:[[a:1, b:2, c:3],...]]]
>> 
>> where "1" a value of the key "a", "2" is a value of the key "b", etc.
>> 
> 
> What do you mean by "multi-level"? For example, from your example, by
> multi- level do you mean that in order to access the value in the a:1 key
> value pair, the map goes something like:
> 
> example_map[1][2][a] == 1 ?

Yes, well almost:

example_map[1][2] (without [a])

-- 
Victor Porton - http://portonvictor.org

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Generating multi-level associative arrays Victor Porton <porton@narod.ru> - 2013-06-22 21:19 +0300
  Re: Generating multi-level associative arrays Rui Maciel <rui.maciel@gmail.com> - 2013-06-23 08:30 +0100
    Re: Generating multi-level associative arrays Victor Porton <porton@narod.ru> - 2013-06-23 15:16 +0300
      Re: Generating multi-level associative arrays Rui Maciel <rui.maciel@gmail.com> - 2013-06-23 16:02 +0100
        Re: Generating multi-level associative arrays Victor Porton <porton@narod.ru> - 2013-06-23 18:06 +0300
          Re: Generating multi-level associative arrays Rui Maciel <rui.maciel@gmail.com> - 2013-06-23 18:52 +0100
            Re: Generating multi-level associative arrays Victor Porton <porton@narod.ru> - 2013-06-24 14:52 +0300
              Re: Generating multi-level associative arrays Victor Porton <porton@narod.ru> - 2013-06-24 14:53 +0300
  Solved: Generating multi-level associative arrays Victor Porton <porton@narod.ru> - 2013-06-24 20:36 +0300

csiph-web