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 #33731 is a reply to message #33730] Thu, 23 January 2003 12:16 Go to previous messageGo to previous message
kashyap is currently offline  kashyap
Messages: 26
Registered: April 1993
Junior Member
Try

value=(my_array[[2147483647L]])[0]

where the "[[.]]" returns an array and the "(.)[0]" ensures that the
output is a scalar, and 2147483647L = 2L^(31L)-1L is the largest
possible I*4 number you can have and surely no will have an array
bigger than that.

vinay

In article <Pine.LNX.4.33.0301231237280.25514-100000@hapuna.ess.sunysb.edu>,
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.
>
> Thanks
> Chad Bender
>
>


--
____________________________________________________________ __________________
kashyap@head-cfa.harvard.edu 617 495 7173 [CfA/P-143] 617 496 7173 [F]
[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 21:18:51 PDT 2025

Total time taken to generate the page: 0.48431 seconds