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

Home » Public Forums » archive » Subscripting arrays.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Subscripting arrays. [message #84150] Thu, 02 May 2013 12:40 Go to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
So someone showed me this and I'm trying to wrap my head around it. Sorry if it's already posted, I didn't know how to begin to search The Group for it...


Create an array:

a = intarr(3)

Using IDL 8, subscript with 4 (ie. an index that's too large and should be out of bounds)

a[4]=3

Obviously, this crashes.

Conversely subscript with a negative index:

a[-1]=2

does what you expect.

But, now subscript the array, WITH an array:

a[[4]]=2

voila. It works, and simply truncates to the last element of the array... Spooky. Now do that with a negative index:

a[[-1]]=4

Like before, it works. But now, it doesn't wrap the index, but rather truncates to the first element of the array.

Hmm.. I can't tell if this is the designed behavior, because I have a hard time describing it --- it's easier to show it.


All the best,
Russell
[Message index]
 
Read Message
Read Message
Previous Topic: WINDOW: Unable to connect to X Windows display: localhost:10.0
Next Topic: Re: WINDOW: Unable to connect to X Windows display: localhost:10.0

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

Current Time: Wed Oct 08 17:06:43 PDT 2025

Total time taken to generate the page: 0.00494 seconds