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 #89919 is a reply to message #89918] Wed, 24 December 2014 20:49 Go to previous messageGo to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Wednesday, December 24, 2014 5:11:54 PM UTC-7, 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

And to make it even more convenient, you can simply append the subscripts inside the first set of brackets and it will automatically descend into the sub-hashes:

IDL> print,person['Colorado', 'Denver']
2

Happy Holidays,
Chris
[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 13:48:02 PDT 2025

Total time taken to generate the page: 0.02012 seconds