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

Home » Public Forums » archive » Re: last array index subscript
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: last array index subscript [message #33730] Thu, 23 January 2003 12:33 Go to previous message
notspecified is currently offline  notspecified
Messages: 14
Registered: February 2002
Junior Member
On Thu, 23 Jan 2003 12:50:30 -0500, Chad Bender
<cbender@mail.astro.sunysb.edu> wrote:

> Hi --
>
> Is there a way in IDL to directly reference the last element of a vector
> without first determining how many elements the vector contains?
>
> For example, something like:
>
> n=N_Elements(my_array)
> value=my_array[n-1]
>
> except without having to make the call to N_Elements. Granted, avoiding
> the N_Elements call probably doesn't save a lot of time. But I figured
> that with all of the complicated syntax that IDL accepts, there might be a
> direct way to do this. The Bldg Apps guide says you can extract a
> subarray from some element e to the end of the array like this:
>
> subarray=my_array[e:*]
>
> So it seems to me that IDL knows what that last index is. I tried
> something like:
>
> value=my_array[*-1], but (not unexpectedly) this caused a syntax error.
>
> I figure that what I want is probably impossible, but if anyone knows how
> to do it your advice is appreciated.
>

Well, sigh, how about

last = my_array[(size(my_array))[1]-1]


Matt Feinstein does not include his email address
in the text of usenet postings.
--------
Harvard Law of Automotive Repair: Anything that goes away
by itself will come back by itself.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Cropping of IDLgrVolume?
Next Topic: Re: formatting array output?

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

Current Time: Fri Oct 10 00:08:18 PDT 2025

Total time taken to generate the page: 1.04264 seconds