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

Home » Public Forums » archive » Negative array indices
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: Negative array indices [message #73902 is a reply to message #73811] Thu, 02 December 2010 17:40 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Dec 2, 7:54 pm, b_gom <b_...@hotmail.com> wrote:
> I guess this leads to this behaviour:
> IDL> x=findgen(10)
> IDL> print,x[-4:0]
> % Illegal subscript range: X.
>
> because this gets translated to:
> IDL> print,x[6,0]
> which isn't allowed.

Not allowed just because you are trying to decrease the index with a
positive stride (it will never get to 0 starting from 5 and adding
increments of 1). This does work:

IDL> x=findgen(10)
IDL> print,x[-4:0:-1]
6.00000 5.00000 4.00000 3.00000 2.00000
1.00000 0.00000
IDL> print,x[6:0:-1]
6.00000 5.00000 4.00000 3.00000 2.00000
1.00000 0.00000
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New Graphics Challange
Next Topic: Convolution Kernel

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

Current Time: Tue Dec 02 05:17:49 PST 2025

Total time taken to generate the page: 1.44493 seconds