I'm assuming the "i" is increment and the "a" is assign, but I could not figure out or find the answer. Also, it looks very similar to the non-standard itoa
which I think is confusing.
7 Answers
C++ iota
is not an acronym or an initialism. It is the word “iota”, which is the English spelling of the name of the ninth letter of the Greek alphabet: ι. The lower-case version of the letter is customarily drawn like an English letter i, but without the dot. Depending on your font, the serifs may differ slightly.
The original SGI STL documentation (also mirrored at boost.org) gives this explanation:
The name
iota
is taken from the programming language APL.
Ken Iverson created APL (which stands for “A Programming Language”). In §1.7 “Special vectors” of his 1962 book A Programming Language, he introduced ⍳ (iota) on page 15 as the “interval vector”:
The interval vector ⍳j(n) is defined as the vector of integers beginning with j.
In his 1979 Turing Award lecture, “Notation as a Tool of Thought”, he gave this description of APL's ⍳ function:
For example, the integer function denoted by
⍳
produces a vector of the firstn
integers when applied to the argumentn
, …
So the likeliest answer is that Dr. Iverson wanted a symbol which would remind the user of the word “integer”, the word “interval”, and the use of the letter “i” as a typical integer variable, especially for array subscripting.
Sean Parent suggests that ‘[t]he “ι” symbol was likely chosen because of its use to represent an inclusion map in mathematics.’ He explains his reasoning here.
Sadly, Dr. Iverson died in 2004, several years before this question was even asked on Stack Overflow, so we cannot ask him for a more precise explanation.
By the way, Unicode has two code points for lower-case iota: one for writing Greek and the other for writing APL. The one for writing Greek is ι
, U+03B9, “GREEK SMALL LETTER IOTA”. The one for writing APL is ⍳
, U+2373, “APL FUNCTIONAL SYMBOL IOTA”.
In response to the demands of commenters, I shall further address the etymology of “iota” in this context.
Let's suppose there is a deeper meaning.
According to the Oxford English Dictionary, “iota” is “The name of the Greek letter Ι, ι, corresponding to the Roman I, i; the smallest letter of the Greek alphabet” (smallest physically, not alphabetically, I presume), and also means “The least, or a very small, particle or quantity”. The OED's earliest known usage of this meaning is from Clavis mystica by Daniel Featley in 1636:
Shall we lose, or sleightly pass by, any iota or tittle of the Booke of God?
Clavis mystica describes itself as “a key opening divers difficult and mysterious texts of Holy Scripture”, and this sentence is in particular referring to Matthew 5:18. The 1611 edition of the King James Version has this text for Matthew 5:18:
Transcription:
For verily I say vnto you, Till heauen and earth passe, one iote or one title, shall in no wise passe from the law, till all be fulfilled.
In the original Greek of Matthew 5:18, “iote” is “ἰῶτα”, and “title” (or more modernly, “tittle”) is “κεραία”. The word “κεραία” meant, roughly, “serif” or “apostrophe”. So this Bible verse is referring to the idea of the smallest details, and using “ἰῶτα” to refer to the letter iota in its role as the physically smallest letter of the Greek alphabet.
Featley, as a Bible scholar (he earned a Doctorate of Divinity), could undoubtedly read Greek. I guess he just transliterated the Greek name for the letter, “ιώτα”, into English “iota”. Why didn't he follow the King James translation's spelling, “iote“? I don't know.
Thus we may deduce that the STL function iota
, and its APL antecedent ⍳
, are named, by way of the Bible, after the physically smallest letter of the Greek alphabet “ι”, because these functions produce integers separated by the smallest amount by which integers may be separated.
According to Wikipedia, The Greek letter iota came from the Phoenician letter yōdh.
This is as far afield of programming as I currently wish to go for this question.
-
6
-
10But this just pushes the question back a bit: why did APL call this function
⍳
?– Daniel HCommented Jun 21, 2017 at 15:16 -
1I thought APL used iota because, at least in English, it means roughly, the smallest measurable amount (e.g., "I don't care one iota."). Commented Feb 13, 2018 at 22:07
-
Cool discourse! Let me comment here on your discussion of "iota" Vs "iote" Vs "jot". In ancient language there was not distinction between letters I and J. J is not in Greek alphabet and was not in Roman, so basically all 3 transcriptions referred to the same letter. WP article states that: "The first English language book to make a clear distinction between ⟨i⟩ and ⟨j⟩ was published in 1633", which is 22 years later than the book you refer to.– Peter KCommented Sep 17, 2018 at 10:37
-
1C++ is not very ergonomic is it?. "the English spelling of the name of the ninth letter of the Greek alphabet:" is not exactly something that comes to mind when thinking of iterating a colleciton.. Who thought this was a good idea? And this is "modern" cpp mind you. Commented Jan 22, 2023 at 2:41
Its the greek letter that sometimes gets used in mathematics to denote sets of numbers or unit vectors. In the C++ case, you get a constructed vector set. Nothing to do with itoa.
std::iota
will fill an iterator range with successively incremented values.
To answer your specific question, it actually doesn't stand for anything. Iota (pronounced "eye-oh-duh" or "eye-oh-tuh" in English) is a greek letter with mathematical connotations.
It is standard in C++11, but not in earlier standards.
-
4Most non-English speakers and I don't pronounce it "eye-oh-duh"– phuclvCommented Dec 8, 2016 at 3:55
-
-
5@LưuVĩnhPhúc I can confirm that at least one native English speaker doesn't pronounce it "eye-oh-duh" either - I say "eye-oh-tuh" (where "uh" is the undifferentiated vowel 'ə' in the middle of "math-ə-matical") Commented Oct 31, 2017 at 10:06
-
1to hear it correctly pronounced in English: merriam-webster.com/dictionary/…– tempckeCommented Dec 22, 2020 at 19:25
Oh, I was always under the impression that since std::iota(start,end,0)
essentially stands for
for(size_t i = 0; i < std::distance(start, end) ; i++) { start[i] = i; }
then you essentially "assign i" to each array element, and iota is greek for i, so there.
(I wouldn't be surprised if that was the rationale for the APL choice, mentioned in @robmayoff's answer, although I have no idea whether that's the case.)
I quote from this page: iotashaming where you can find more on the subject.
STL was greatly influenced by Ken Iverson’s work on APL. In Ken’s Turing award lecture from 1979 you will find this phrase:
"For example, the integer function denoted by ι produces a vector of the first N integers."
std::iota
- it is a standard function template in <numeric>
header (NOT in <algorithm>
) available from C++11.
⍳
(iota) is a Greek letter to represent a set of consecutive integers
std::iota
uses that context for generating a contiguous series of increasing values(++val) in the range [first, last).
std::list<int> li(5);
std::iota(li.begin(), li.end(), 3); // 3 4 5 6 7
-
You answer what is
std::iota
, but the question was about the origin of its name.– FedorCommented Nov 7, 2022 at 19:49
for myself, as a non-native english person I "invented" this deciphering:
Incremental Output To Array
in order to be not confused with itoa
iota
a <s>keyword</s> specially declared identifier, whose value is incremented once per definition, but only when you're defining constants.itoa
confusion; I had the same thought.