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

Home » Public Forums » archive » Copying a hash
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: Copying a hash [message #81091 is a reply to message #81003] Tue, 07 August 2012 08:44 Go to previous messageGo to previous message
Matt[3] is currently offline  Matt[3]
Messages: 23
Registered: April 2011
Junior Member
On Monday, August 6, 2012 7:41:12 PM UTC-4, David Fanning wrote:
> Paul van Delst writes:
>
>
>
>> Bummer. To be honest, I'm not sure what the correct behaviour should be. Recursively copy all the components? I guess if
>
>> we think of the numbers and strings as objects also, then the answer should probably be yes.... ? Why duplicate one type
>
>> of object (int, float, or string) but not another (hash or list)? Still... it just doesn't seem right.
>
>
>
> I think this takes us back to the need for a "deep copy" in objects.
>
>
>
> http://www.idlcoyote.com/tips/copy_objects.html
>
>
>
> But, we have only been requesting it for 9 years, I see by
>
> the date on the article. I think the standard is 12 years
>
> before they either fix the problem or consign the requester
>
> to the loony bin. :-)
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Hi Guys,

Thanks for the help, and sorry for somehow missing that rather clear bit of documentation.

Yes, I'm not sure what the behavior should be either when there is a hash within a hash. The default behavior seems likely to cause trouble! Anyway, to copy down through one or two hash levels, the following lines seem to work:

copy=hash()
foreach variable, original, key do copy[key]=original[key, *]

I'm sure there's a smart way of doing this recursively for an indefinite number of levels, but this works for me, for now.

Cheers,

Matt
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: RESOLVE_ROUTINE not finding MEDIAN function?
Next Topic: mosaic

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

Current Time: Thu Oct 09 20:42:20 PDT 2025

Total time taken to generate the page: 0.61558 seconds