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

Home » Public Forums » archive » IDL 8.0 compile_opt changes
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: IDL 8.0 compile_opt changes [message #69452 is a reply to message #69187] Thu, 07 January 2010 09:56 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 1/7/10 8:27 AM, Maarten wrote:
> On Jan 6, 10:25 pm, mgalloy<mgal...@gmail.com> wrote:
>> On 1/6/10 7:01 AM, Maarten wrote:
>>
>>> I do love the idea of negative indices, although I'd like them to mean
>>> the same as in Python. The samples Ive seen so far are off by one.
>>
>> My understanding of the negative indices proposal in IDL was that they
>> would be the same as in Python:
>>
>>>> > a = [1, 2, 3, 4]
>>>> > a[-1]
>> 4
>>>> > a[-2]
>> 3
>
> Yes, in this case it is the same. The (subtle) difference comes in for
> ranges.
>
> Python:
>>>> a = [1,2,3,4]
>>>> a[-1]
> 4
>>>> a[-2]
> 3
>>>> a[1:-1]
> [2, 3]
>
> The last one is the one I'm concerned about, as python does not
> include the last index in the range.
>
> IDL> a = [1,2,3,4]
> IDL> print, a[3]
> 4
> IDL> print, a[1:3]
> 2 3 4
>
> (index 3 is equivalent to index -1).
>
> Now you could say that Python and IDL already disagree here, but the
> off-by-one is worth mentioning anyway.

I think we are agreeing here, but just to be sure: Python and IDL would
be specifying the endpoints of the range in the same way, it's just that
Python always includes the start index and excludes the end index (even
if not using negative indices):

>>> a = [1, 2, 3, 4]
>>> a[1:3]
[2, 3]

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: envi_title_bar.ico missing and null pointer dereferenced error when using .sav file in ENVI
Next Topic: A routine to annotate PS files

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

Current Time: Fri Oct 10 10:32:01 PDT 2025

Total time taken to generate the page: 2.71894 seconds