[ncl-talk] Feature request: Negative indexes

Kyle Griffin ksgriffin2 at wisc.edu
Tue May 10 20:53:27 MDT 2016


Given someone who often finds himself in shoes similar to Alan's, at least
with regard to python, the syntax of x(-1) often slips through my
fingertips in NCL as well.

I also can't think of any immediate downsides, as I believe there is no
acceptable or legal use of negative non-coordinate indices in NCL
currently, and I would think no reasonably constructed code would be
'dependent' on errors thrown by attempting to use such indices.

Lastly, there are a number of times in which I've used syntax such as
x(0:dimsizes(x)-2), which, perhaps unintuitively, reads all but the last 1
item.

Just consider this another vote in favor, pending any future discovery of
downsides.

Thanks for considering...


Kyle

On Tue, May 10, 2016 at 7:17 PM David Brown <dbrown at ucar.edu> wrote:

> I agree that negative indexes would be great and we don't know what
> the downsides are either, although we would probably find out if we
> tried to implement them.
>  -dave
>
> On Tue, May 10, 2016 at 2:41 PM, Alan Brammer <abrammer at albany.edu> wrote:
> > Not sure if this has been brought up before but I’d really like the
> ability to fetch the last index of an array using x(-1), or similarly the
> last n of the array x(-n:)
> >
> > Being in a mostly javascript/python world outside of NCL negative
> indexes have been quite useful.
> >
> > Any plans or possibility of this becoming a thing, or are there
> downsides I’m not thinking of?
> >
> > Thanks,
> >
> > Alan
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk at ucar.edu
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160511/fd2f46ef/attachment.html 


More information about the ncl-talk mailing list