What does iota of std::iota stand for?
Asked Answered
E

6

214

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.

Eatton answered 11/2, 2012 at 23:12 Comment(8)
Possibly from APL? The Greek letter Iota was used to generate a vector of consecutive integers.Mashie
If you think that's confusing, Google Go makes iota a <s>keyword</s> specially declared identifier, whose value is incremented once per definition, but only when you're defining constants.Bromine
Agreed about the itoa confusion; I had the same thought.Eastwards
en.cppreference.com/w/cpp/algorithm/iotaMas
Funny, I somehow thought the name was from taking "atoi" backwards – sort of the inverse. Does not really make sense though.Peridot
isn't seqence or range a better name?Benedictine
The use of i for an integer originates in FORTRAN IV. Any variable starting with the letters from i to n is implicitly an INteger in early Fortran. All others are real numbers. Variables could be explicitly defined as either numeric type. Not a direct response to OP but to other answers and comments.Featherstone
@Bromine FWIW, Go inherited it from Limbo.Shew
S
268

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 first n integers when applied to the argument n, …

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:

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.

Service answered 11/2, 2012 at 23:23 Comment(6)
So why did you introduce the typo? ;-)Corriveau
But this just pushes the question back a bit: why did APL call this function ?Interdenominational
I thought APL used iota because, at least in English, it means roughly, the smallest measurable amount (e.g., "I don't care one iota.").Allies
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.Saltzman
C++ 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.Jig
This greek letter sounds more like Yota, Йота.Sabotage
P
35

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.

Pilferage answered 11/2, 2012 at 23:22 Comment(0)
U
28

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.

Underling answered 11/2, 2012 at 23:24 Comment(4)
Most non-English speakers and I don't pronounce it "eye-oh-duh"Katiakatie
eye-yacht-ah? I don't care one iota (I do really) :)Tarrsus
@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")Naresh
to hear it correctly pronounced in English: merriam-webster.com/dictionary/…Uganda
M
4

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.)

Militarism answered 25/4, 2016 at 7:57 Comment(0)
G
1

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."

Galloping answered 14/10, 2019 at 9:38 Comment(0)
P
0

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
Pyridoxine answered 11/5, 2021 at 9:55 Comment(1)
You answer what is std::iota, but the question was about the origin of its name.Autostrada

© 2022 - 2024 — McMap. All rights reserved.