comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Nested data structures
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Nested data structures [message #89920 is a reply to message #89918] Fri, 26 December 2014 12:02 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Thanks Mike and Chris for pointing me in the right direction.

I want to build the data structure one step at a time, and it took me a while to figure out how to add new cities, but concatenation works nicely. --Wayne

IDL> person['Colorado'] += hash('FtCollins',5)
IDL> person
{
"Colorado": {
"Boulder": 1,
"FtCollins": 5,
"Denver": 2
},
"Arizona": {
"Tucson": 3,
"Phoenix": 4
}
}


On Wednesday, December 24, 2014 7:11:54 PM UTC-5, Mike Galloy wrote:
> On 12/24/14, 2:29 PM, wlandsman wrote:
>> I am trying to build a data structure that will allow me to specify a person by his State, city, street and street. (This is not my actual need, but it is analogous.) Thus I might specify (as metacode)
>>
>> ['Colorado']['Boulder']['Pearl'][9990] = 'John'
>>
>> I assume this can be done with nested hashes or dictionaries, but I am having difficulty figuring out how to start. I started writing something like
>>
>> person = [hash('colorado',['boulder','Denver'], hash('Arizona',[Tuscon','Phoenix'])
>>
>> but I get lost in making the nesting clear. thanks for any help. --Wayne
>>
>>
>
> Is something like this what you are trying to do?
>
> IDL> person = hash('Colorado', hash('Boulder', 1, 'Denver', 2),
> 'Arizona', hash('Tucson', 3, 'Phoenix', 4))
> IDL> (person['Colorado'])['Denver']
> 2
>
> Mike
> --
> Michael Galloy
> www.michaelgalloy.com
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
> Research Mathematician
> Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDLBridge problem with unknown ExecuteTimer method
Next Topic: ERROR: Attempt to subscript B with is out of range

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:43:10 PDT 2025

Total time taken to generate the page: 0.01586 seconds