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.
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.
⍳
? –
Interdenominational 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.
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
std::iota
, but the question was about the origin of its name. –
Autostrada © 2022 - 2024 — McMap. All rights reserved.
iota
a <s>keyword</s> specially declared identifier, whose value is incremented once per definition, but only when you're defining constants. – Bromineitoa
confusion; I had the same thought. – Eastwards