i never got this its always in my tutial bookfor i in range(...)
why i
Collapse
This topic is closed.
X
X
-
mr_vocabTags: None
-
Ben Finney
Re: why i
On Tue, 25 May 2004 08:10:51 +1000, mr_vocab wrote:[color=blue]
> i never got this its always in my tutial bookfor i in range(...)[/color]
"Index". i.e., the variable will be the index of an array you want to
iterate over.
The usage of "i" was promulgated by the FORTRAN language, which allowed
only single-letter variable names (and was all upper case, too, so it
was actually I). The FOR statement was commonly used to iterate over an
array, and I and J were the commonly used index variables for that
purpose.
--
\ "If you write the word 'monkey' a million times, do you start |
`\ to think you're Shakespeare?" -- Steven Wright |
_o__) |
Ben Finney <http://bignose.squidly .org/>
-
Aquarion
Re: why i
On Tue, 25 May 2004 08:10:51 +1000, "mr_vocab"
<amireallyfat@y ahoo.com.au> wrote:
[color=blue]
>i never got this its always in my tutial bookfor i in range(...)[/color]
It's arbitrary, but some programmers use "i" in an iteration to either
stand for iteration or index.
--
Aq2
Comment
-
Duncan Booth
Re: why i
Ben Finney <bignose-hates-spam@and-benfinney-does-too.id.au> wrote in
news:slrncb5s1p .21a.bignose-hates-spam@rose.local domain.fake:
[color=blue]
> On Tue, 25 May 2004 08:10:51 +1000, mr_vocab wrote:[color=green]
>> i never got this its always in my tutial bookfor i in range(...)[/color]
>
> "Index". i.e., the variable will be the index of an array you want to
> iterate over.
>
> The usage of "i" was promulgated by the FORTRAN language, which allowed
> only single-letter variable names (and was all upper case, too, so it
> was actually I). The FOR statement was commonly used to iterate over an
> array, and I and J were the commonly used index variables for that
> purpose.[/color]
Close, but not quite there.
Early versions of Fortran supported variable names up to 6 characters long.
Actually, Fortran always allowed longer variable names, but only the first
6 were significant. I believe the reason why it was 6 characters was that
with a 36bit word length and 64 characters in your character set (as you
say, no lower case), you could exactly pack a 6 character string into 1
machine word.
The actual reason why everyone uses I and then J as the for loop indexes
was that Fortran, by default, assumed all variables starting with letters
from I-N were integer, and all other variable names were real. Integer
names starting with I was presumably chosen for its mnemonic value and the
other letters then follow on in sequence, presumably far enough for what
the original language designers thought was a reasonable 20:6 split real to
integer variables.
Obviously you are going to pick some really meaningful :^) 6 character name
for that all important linear-regression library function but for a simple
loop, why bother.
Comment
-
Peter Hansen
Re: why i
Duncan Booth wrote:
[color=blue]
> The actual reason why everyone uses I and then J as the for loop indexes
> was that Fortran, by default, assumed all variables starting with letters
> from I-N were integer, and all other variable names were real. Integer
> names starting with I was presumably chosen for its mnemonic value and the
> other letters then follow on in sequence, presumably far enough for what
> the original language designers thought was a reasonable 20:6 split real to
> integer variables.[/color]
Does the FORTRAN usage precede or follow the similar common use by
mathematicians?
My guess is that subscripts i, j, k have been used so for much longer
than FORTRAN has existed, or computers for that matter.
The idea that 'i' is mnemonic for 'integer' is interesting, though.
If the mathematical field is really the origin, rather than FORTRAN,
it would be interesting to know if that was how "they" picked it.
Googling to little avail, the best I could find to help was Hilbert's
1900 address on "23 Mathematical Problems" which he gave to the Int'l
Congress of Mathematics in Paris, proving a usage which predates
FORTRAN by 50-some years. The interesting page maintained by Jeff
Miller at http://members.aol.com/jeff570/mathsym.html makes no mention
of the topic.
-Peter
Comment
-
Richard Brodie
Re: why i
"Peter Hansen" <peter@engcorp. com> wrote in message news:N9KdnVD1v9 2IlS7d4p2dnA@po wergate.ca...
[color=blue]
> The idea that 'i' is mnemonic for 'integer' is interesting, though.
> If the mathematical field is really the origin, rather than FORTRAN,
> it would be interesting to know if that was how "they" picked it.
>
> Googling to little avail, the best I could find to help was Hilbert's
> 1900 address on "23 Mathematical Problems" which he gave to the Int'l
> Congress of Mathematics in Paris, proving a usage which predates
> FORTRAN by 50-some years.[/color]
I would assume vector algeba was the origin; Google can go back
to 1843 on that line: http://www.wordiq.com/definition/Quaternion
That suggests that i, j, k notation is an extension of complex notation
so i must be the Euler i (1777) presumably standing for imaginary.
Comment
-
Peter Hansen
Re: why i
Richard Brodie wrote:
[color=blue]
> "Peter Hansen" <peter@engcorp. com> wrote in message news:N9KdnVD1v9 2IlS7d4p2dnA@po wergate.ca...[color=green]
>>The idea that 'i' is mnemonic for 'integer' is interesting, though.
>>If the mathematical field is really the origin, rather than FORTRAN,
>>it would be interesting to know if that was how "they" picked it.
>>
>>Googling to little avail, the best I could find to help was Hilbert's
>>1900 address on "23 Mathematical Problems" which he gave to the Int'l
>>Congress of Mathematics in Paris, proving a usage which predates
>>FORTRAN by 50-some years.[/color]
>
> I would assume vector algeba was the origin; Google can go back
> to 1843 on that line: http://www.wordiq.com/definition/Quaternion
>
> That suggests that i, j, k notation is an extension of complex notation
> so i must be the Euler i (1777) presumably standing for imaginary.[/color]
I'm not sure we should consider that early usage to be of
the same type. The Hilbert usage is as a subscript, which
corresponds to (I think) the reason for using i,j,k as indices
in a program loop: to index into a vector, as in M[i] and such.
-Peter
Comment
-
Grant Edwards
Re: why i
On 2004-05-25, Duncan Booth <me@privacy.net > wrote:
[color=blue]
> The actual reason why everyone uses I and then J as the for loop indexes
> was that Fortran, by default, assumed all variables starting with letters
> from I-N were integer,[/color]
That that was because people always used i,j,k as indexes.
--
Grant Edwards grante Yow! Did you find a
at DIGITAL WATCH in YOUR box
visi.com of VELVEETA??
Comment
-
Dennis Lee Bieber
Re: why i
On 25 May 2004 16:35:29 +0950, Ben Finney
<bignose-hates-spam@and-benfinney-does-too.id.au> declaimed the
following in comp.lang.pytho n:
[color=blue]
>
> The usage of "i" was promulgated by the FORTRAN language, which allowed
> only single-letter variable names (and was all upper case, too, so it[/color]
That must have been a really old version of FORTRAN -- all
versions I've encountered allowed for, at least, 6 significant
characters in variable names. (This goes back to F-IV/F-66). BASIC was
limited to one or two characters.
I think, at least on my college machine, part of the limit was
that the back-end assembler stage only accepted 8 characters, and the
compiler tended to prefix the FORTRAN variables with special markers.
However, FORTRAN had the "Indian" <G> {my mnemonic for the
range} -- the default for undeclared variables beginning in the range I
... N is INTEGER. A .. H, O .. Z are REAL/FLOAT.
--[color=blue]
> =============== =============== =============== =============== == <
> wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wulfraed@dm.net | Bestiaria Support Staff <
> =============== =============== =============== =============== == <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]
Comment
-
Steve Holden
Re: why i
Dennis Lee Bieber wrote:
[color=blue]
> On 25 May 2004 16:35:29 +0950, Ben Finney
> <bignose-hates-spam@and-benfinney-does-too.id.au> declaimed the
> following in comp.lang.pytho n:
>
>[color=green]
>>The usage of "i" was promulgated by the FORTRAN language, which allowed
>>only single-letter variable names (and was all upper case, too, so it[/color]
>
>
> That must have been a really old version of FORTRAN -- all
> versions I've encountered allowed for, at least, 6 significant
> characters in variable names. (This goes back to F-IV/F-66). BASIC was
> limited to one or two characters.
>[/color]
[...]
I think the original author was confusing Fortran and BASIC. I used
Fortran II back in 1968, and that definitely allowed six-character names.
regards
Steve
Comment
-
Ben Finney
Re: why i
On Tue, 25 May 2004 15:44:25 GMT, Dennis Lee Bieber wrote:[color=blue]
> On 25 May 2004 16:35:29 +0950, Ben Finney wrote:[color=green]
>> The usage of "i" was promulgated by the FORTRAN language, which
>> allowed only single-letter variable names (and was all upper case,[/color]
>
> That must have been a really old version of FORTRAN -- all versions
> I've encountered allowed for, at least, 6 significant characters in
> variable names. (This goes back to F-IV/F-66). BASIC was limited to
> one or two characters.[/color]
Yes, I've since been corrected; FORTRAN allowed at least 6 characters
for variable names.
I was confused by my memory of the "I through N" rule of FORTRAN's
integer/real split; for some reason that translated into erroneously
thinking the variables were only one character in length.
I'm in agreement with others that FORTRAN was, in this regard, influeced
by the existing mathematical formula convention of 'i', 'j', 'k' etc.
for vector subscripts. Since FORTRAN, as the language name indicates,
was initially used for mathematical formula algorithms, the use of a FOR
loop to iterate through a vector (or array) was common, and thus using
the variable I for the index would seem natural to a
mathematically-oriented programmer.
--
\ "There is no reason anyone would want a computer in their |
`\ home." -- Ken Olson, president, chairman and founder of |
_o__) Digital Equipment Corp., 1977 |
Ben Finney <http://bignose.squidly .org/>
Comment
-
Greg Ewing
Re: why i
Dennis Lee Bieber wrote:[color=blue]
> However, FORTRAN had the "Indian" <G> {my mnemonic for the
> range} -- the default for undeclared variables beginning in the range I
> .. N is INTEGER. A .. H, O .. Z are REAL/FLOAT.[/color]
Hence the well-known saying, "GOD is REAL, unless
declared INTEGER."
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
Comment
-
mr_vocab
Re: why i
great thanks
"mr_vocab" <amireallyfat@y ahoo.com.au> wrote in message
news:40b2e204$1 _1@news.iprimus .com.au...[color=blue]
> i never got this its always in my tutial bookfor i in range(...)
>
>
>[/color]
Comment
Comment