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

Home » Public Forums » archive » Re: what is the highest subscript in the array?!?
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
Re: what is the highest subscript in the array?!? [message #70768] Thu, 06 May 2010 21:27 Go to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 5/6/10 9:32 pm, Craig Markwardt wrote:
> On May 6, 10:26 pm, Michael Galloy<mgal...@gmail.com> wrote:
>> munka<mynameismu...@gmail.com> wrote:
>>> Hello team,
>>
>>> I find myself wanting to use the highest subscript in an array and
>>> coding "flux[n_elements(flux)-1]"... I seem to remember seeing a
>>> shortcut on here, and I can't remember what it is.
>>
>> You are stuck using that until IDL 8.0 comes out, then you can use -1.
>
> Really? First of all a[-1] used to be an error and now it won't be.
> That could be dangerous change of expectations.
>
> Craig

It does not change valid existing behavoir:

IDL> print, a[[-1]]
0.00000

It would just change conditions which would have caused errors before.
So code that caught the out-of-bounds runtime error instead of just
checking the index will break.

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
Re: what is the highest subscript in the array?!? [message #70769 is a reply to message #70768] Thu, 06 May 2010 21:22 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Craig Markwardt writes:

> Really? First of all a[-1] used to be an error and now it won't be.
> That could be dangerous change of expectations.

Yeah, well, IDL 8.0 looks like a dangerous change of
expectations to me. And I mean that in a happy sort
of way. ;-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: what is the highest subscript in the array?!? [message #70770 is a reply to message #70769] Thu, 06 May 2010 21:21 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 5/6/10 8:44 pm, munka wrote:
> On May 6, 9:26 pm, Michael Galloy<mgal...@gmail.com> wrote:
>> munka<mynameismu...@gmail.com> wrote:
>>> Hello team,
>>
>>> I find myself wanting to use the highest subscript in an array and
>>> coding "flux[n_elements(flux)-1]"... I seem to remember seeing a
>>> shortcut on here, and I can't remember what it is.
>>
>> You are stuck using that until IDL 8.0 comes out, then you can use -1.
>>
>> Mike
>> --www.michaelgalloy.com
>> Research Mathematician
>> Tech-X Corporation
>
> :(
> -1 doesn't even work.
>
> Also, clicking on your signature link brings me to "http://
> www.google.com/www.michaelgalloy.com" :\

You need IDL 8.0:

IDL> a = findgen(10)
IDL> print, a[-1]
9.00000
IDL> print, a[-2]
8.00000

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
Re: what is the highest subscript in the array?!? [message #70771 is a reply to message #70770] Thu, 06 May 2010 20:32 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On May 6, 10:26 pm, Michael Galloy <mgal...@gmail.com> wrote:
> munka <mynameismu...@gmail.com> wrote:
>> Hello team,
>
>> I find myself wanting to use the highest subscript in an array and
>> coding "flux[n_elements(flux)-1]"... I seem to remember seeing a
>> shortcut on here, and I can't remember what it is.
>
> You are stuck using that until IDL 8.0 comes out, then you can use -1.

Really? First of all a[-1] used to be an error and now it won't be.
That could be dangerous change of expectations.

Craig
Re: what is the highest subscript in the array?!? [message #70772 is a reply to message #70771] Thu, 06 May 2010 19:44 Go to previous messageGo to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On May 6, 9:26 pm, Michael Galloy <mgal...@gmail.com> wrote:
> munka <mynameismu...@gmail.com> wrote:
>> Hello team,
>
>> I find myself wanting to use the highest subscript in an array and
>> coding "flux[n_elements(flux)-1]"... I seem to remember seeing a
>> shortcut on here, and I can't remember what it is.
>
> You are stuck using that until IDL 8.0 comes out, then you can use -1.
>
> Mike
> --www.michaelgalloy.com
> Research Mathematician
> Tech-X Corporation

:(
-1 doesn't even work.

Also, clicking on your signature link brings me to "http://
www.google.com/www.michaelgalloy.com" :\
Re: what is the highest subscript in the array?!? [message #70773 is a reply to message #70772] Thu, 06 May 2010 19:26 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
munka <mynameismunka@gmail.com> wrote:
> Hello team,
>
> I find myself wanting to use the highest subscript in an array and
> coding "flux[n_elements(flux)-1]"... I seem to remember seeing a
> shortcut on here, and I can't remember what it is.

You are stuck using that until IDL 8.0 comes out, then you can use -1.

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
Re: what is the highest subscript in the array?!? [message #70866 is a reply to message #70772] Thu, 06 May 2010 21:30 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 5/6/10 8:44 pm, munka wrote:

[snipped]

> Also, clicking on your signature link brings me to "http://
> www.google.com/www.michaelgalloy.com" :\

Not sure what Google is doing there; it works fine in my newsreader, but
Google Groups is doing something funky.

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
Re: what is the highest subscript in the array?!? [message #70867 is a reply to message #70769] Thu, 06 May 2010 21:29 Go to previous message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
IDL Version 6.2 (linux x86 m32). (c) 2005, Research Systems, Inc.


Maybe I'll convince the college that I go to to upgrade.... but until
then, I'm stuck with 6.2....


On an unrelated note, check out this cool picture!
http://img.photobucket.com/albums/v461/munka123/M101.png
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: passing an idl function to a c-code ?
Next Topic: Re: Plotting spherical slice surfaces

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

Current Time: Sun Oct 12 12:07:42 PDT 2025

Total time taken to generate the page: 0.64030 seconds