Array indexing "Feature" [message #28470] |
Wed, 12 December 2001 13:52 |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
Hi All,
One of my colleagues has noted something apparently screwy in the
indexing of
arrays.
e.g. a = indgen(10)
print, a(9) -> you get 9
print, a(10) -> you get an error, as expected for a zero-based
index
but if you access the array with the index as a vector, it seems to
truncate the index to the maximum allowable:
print, a([10]) -> you get 9
print, a([666]) -> you get 9
Similarly:
print, a(-1) -> you get an error
print, a([-1]) -> you get 0
This feature holds good for IDL 5.2 and 5.4 on OpenVMS and for 5.5 on
Windows.
Where, Oh where in the manuals does it describe this?
Andrew
------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Salisbury electrons
South Australia 5108
Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ ---------
|
|
|