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

Home » Public Forums » archive » Re: HASH -- bug, or "feature"?
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: HASH -- bug, or "feature"? [message #75875 is a reply to message #75874] Wed, 20 April 2011 13:33 Go to previous messageGo to previous message
Mark Piper is currently offline  Mark Piper
Messages: 198
Registered: December 2009
Senior Member
Here's an example of the technique Mike suggests:

IDL> names = list('red', 'green', 'blue')
IDL> colors = hash()
IDL> colors[names[0]] = [255,0,0]
IDL> colors[names[1]] = [0,255,0]
IDL> colors[names[2]] = [0,0,255]

IDL> print, colors ; order is mangled
green: 0 255 0
blue: 0 0 255
red: 255 0 0

IDL> foreach n, names do print, n, colors[n] ; ordered
red 255 0 0
green 0 255 0
blue 0 0 255

This also works with an array (and a FOR loop) instead of a list.

mp
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HASH -- bug, or "feature"?
Next Topic: IDL syntax highlighting for GeSHI

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

Current Time: Fri Oct 10 23:19:32 PDT 2025

Total time taken to generate the page: 0.72119 seconds