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

Home » Public Forums » archive » Re: shorten a vector
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: shorten a vector [message #21627 is a reply to message #21625] Fri, 08 September 2000 02:04 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Liam Gumley wrote:
>
> Andrew <noymer@my-deja.com> wrote in message
> news:8p9gie$6m5$1@nnrp1.deja.com...
>> What's the easiest way to shorten an array by n units
>> by chopping off the first n elements of the array.
>>
>> E.G: I want to make [ 4 6 7 20 15 ]
>>
>> Into [ 6 7 20 15]. Here n=1.
>
> a =
> n = 1
> print, a[(0 + n):*]
> 6 7 20 15
>
> To make it more general, use n_elements to get the index of the last
> element:
>
> last = n_elements(a) - 1
> n = 1
> print, a[(0 + (n < last)):*]
> 6 7 20 15
> n = 4
> print, a[(0 + (n < last)):*]
> 15
> n = 10
> print, a[(0 + (n < last)):*]
> 15
>
> Cheers,
> Liam.
> http://cimss.ssec.wisc.edu/~gumley

Good. But why 0+ ???
It works also for
print, a[n<last:*]

Martin


--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: shorten a vector
Next Topic: DISPLAY bug fixed

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

Current Time: Fri Oct 10 20:41:55 PDT 2025

Total time taken to generate the page: 1.27975 seconds