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

Home » Public Forums » archive » Strange arrary indexing quirk?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Strange arrary indexing quirk? [message #77182] Thu, 11 August 2011 18:12
Matt Francis is currently offline  Matt Francis
Messages: 94
Registered: May 2010
Member
I stumbled across this strange behaviour:

foo = indgen(2,2)
print,foo[0,10]
< gives an error, since the second index is out of range>

however,

indx = indgen(5)
print,foo[0,indx]
0
2
2
2
2

Does anyone have any insight into why this happens? I'd expect the
second line to also throw an error. A lot of the inner workings of IDL
seem pretty arcane and hard to guess at before you try things...

I was being lazy/naughty and using a catch statement to detect when an
index went out of range, which I knew would happen very occaisonally
and was trying to avoid the performance hit of checking for it every
time. This round off instead of an error behaviour made sure that plan
didn't work!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Wavelength Calibration
Next Topic: Re: Strange arrary indexing quirk?

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

Current Time: Wed Oct 08 15:36:40 PDT 2025

Total time taken to generate the page: 0.00427 seconds