3 ms·
> iterating through a for loop using i is a well-established idiom that everyone instantly understands. Give that count was useless anyway, i is preferable sinc
by wyldfire 11y ago
> iterating through a for loop using i is a well-established idiom that everyone instantly understands. Give that count was useless anyway, i is preferable since it saves 4 characters.
"Where does this idiom come from?" you might ask. Well, if I recall it's mostly due to languages like Fortran which implicitly typed identifiers starting with I through N as integers.
- ChuckMcM 11y agoexactly right. Some jokes about writing fortran in any language focus on the use of "I, J, and K" as indexes and counters. But in mathematics the common iterator in a summation is also i, j, and k so mathematicians sometimes claim ownership of the use of i as a count.
- kps 11y agoFortran, like most early programming languages, was explicitly modelled on mathematical notation. There was debate whether allowing multi-letter variable names was worth the loss of implicit multiplication. But today's programmer can write COBOL in any language.