Array indexing surprises [message #72483] |
Tue, 07 September 2010 15:01 |
Larry Kneller
Messages: 2 Registered: September 2010
|
Junior Member |
|
|
I received this question from a guy I work with.
The main thing I can't explain here is that if I index an array with
too big
a number where the index is an array, then it behaves as though there
is
no problem.
Here is an example program to illustrate:
pro jrdc_colors
color=['red','white','blue']
icol=[3]
print,color[icol] ; blue
; NO ERROR, NO CRASH IN IDL 7 or 8!
icol2 = [-3,-2,-1,0,1,2,3,4]
print,color[icol2] ; red red red white blue blue blue
print,color[-3] ; blue
print,color[-2] ; white
print,color[-1] ; red
print,color[3] ; ERROR IN IDL 7 AND 8
end
I don't know whether this is a bug or it is working as
planned. It seems like the first two examples in this
code will cause problems with where statements.
-Larry
|
|
|