[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Negative indexes in address@hidden:off:length}

From: Maarten Billemont
Subject: Re: Negative indexes in address@hidden:off:length}
Date: Thu, 30 Jun 2011 14:45:24 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110624 Thunderbird/5.0

On 30/06/11 14:15, Greg Wooledge wrote:
> On Wed, Jun 29, 2011 at 06:41:25PM +0200, Maarten Billemont wrote:
>> For those to whom a cursor between elements seems confusing: think of your prompt's cursor and imagine an element is a single character.
> No wonder this makes no sense to me.  Have you actually looked at the
> cursor in a terminal?  I use rxvt, but xterm is the same: the cursor is
> a black[1] rectangle that *overlies* one of the characters, not a skinny
> little wedge/line that sits *between* characters.
> The only time I've ever seen a cursor that is *between* characters is
> in GUI stuff, like a textarea in Firefox.  But for people like me,
> that's the oddball case, not the norm.  I certainly wouldn't expect a
> programming language to work like this.
> [1] Or white, if you are one of those people who use a dark background.
> Or possibly amber or green, if you're *really* old school.

My cursor is also a block, but perhaps you use vim. Write abcabc in a vim document, then select the second a. You move your cursor so that the block is on the a or the line is in front of it. You go into visual mode and go forward by one. address@hidden:0:1}.

Now instead of going forward, go backward one (address@hidden:0:-1}) and you'll have selected the c.

It really doesn't matter whether your cursor is a block or a line. To select elements from a set, you need a starting point and a direction, and IMO, pretending that address@hidden:0:1} should be the same thing as address@hidden:0:-1} is by far the more confusing way to think about arrays.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]