develooper Front page | perl.perl5.porters | Postings from January 2014

Re: Range idea

Thread Previous | Thread Next
From:
Zefram
Date:
January 23, 2014 19:39
Subject:
Re: Range idea
Message ID:
20140123193852.GM21945@fysh.org
Aristotle Pagaltzis wrote:
>It bothers me that indexing from the front of the list is 0-based but
>indexing from the end of the list is 1-based.

I view them both as being zero-based, but with the indexes referring
to the gaps between elements rather than to the elements themselves.
Zero refers to either edge of the array.  Think about how negative
indices work with splice().  Then when you're referring to an element
you use the index of that element's left edge.  It's only at that last
step that any asymmetry arises.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About