Sujet : Re: Loops (was Re: do { quit; } else { })
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 16. Apr 2025, 17:28:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vtolrv$2j3s1$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Mozilla Thunderbird
On 4/16/25 11:18, Michael S wrote:
On Wed, 16 Apr 2025 10:47:56 -0400
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
bart <bc@freeuk.com> writes:
On 16/04/2025 06:35, Janis Papanagnou wrote:
>
>
So here, 0% of such loops have a step other than 1. THAT's what I
mean by 'unusual'.
>
The files easily accessible to me contain 13965 for statements, of
which 596 used a step other than 1.
>
In quoted statement "1" was meant to cover both +1 and -1.
Most of that code was part of packages I installed rather than code that
I myself wrote. I naively assumed that any for loop where someone used
+=, it would be for a stride other than 1 - why use "+=1" rather than
"++"? However, 37 of those cases did in fact use "+= 1". None of them
used "-= 1". Indeed, I didn't find any cases of for statements using -=.
I would be surprised to find out that non-units strides are relatively
common (say, above 0.1%)
559/13965 is about 4%.
outside of several specialized fields, like
linear algebra and image processing.
No, for most of them it was some other reason, such as putting tab stops
after ever 4 characters.