C++ std::iota 的 iota 代表什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9244879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does iota of std::iota stand for?
提问by Jesse Good
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.
我假设“i”是递增的,而“a”是赋值的,但我无法弄清楚或找到答案。此外,它看起来与itoa
我认为令人困惑的非标准非常相似。
回答by rob mayoff
From the original SGI STL documentation:
The name iota is taken from the programming language APL.
iota 的名称取自编程语言 APL。
In his Turing Award lecture, Ken Iverson (inventor of APL) said this:
在他的图灵奖演讲中,Ken Iverson(APL 的发明者)是这样说的:
For example, the integerfunction denoted by
ι
produces a vector of the firstn
integers when applied to the argumentn
, …
例如,由表示的整数函数在应用于参数时
ι
会产生第一个n
整数的向量n
,...
That ι
is the lower-case Greek letter iota.
那ι
是小写的希腊字母 iota。
In the quote above, I typed ι
, U+03B9, “GREEK SMALL LETTER IOTA”, but Unicode actually has a dedicated code point for APL's iota: ?
is U+2373, “APL FUNCTIONAL SYMBOL IOTA”.
在上面的引用中,我输入了ι
, U+03B9, “GREEK SMALL LETTER IOTA”,但 Unicode 实际上有一个专门用于 APL 的 iota 的代码点:?
是U+2373, “APL FUNCTIONAL SYMBOL IOTA”。
In response to the demands of commenters, I shall further address the etymology of “iota” in this context.
应评论者的要求,我将在此背景下进一步讨论“iota”的词源。
The likeliest answer is that Ken Iverson wanted a symbol which would remind the user of the word “integer” and the use of the letter “i” as a typical integer variable, especially for array subscripting.
最可能的答案是 Ken Iverson 想要一个符号来提醒用户“整数”这个词以及字母“i”作为典型整数变量的使用,特别是对于数组下标。
But 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 mysticaby Daniel Featley in 1636:
根据牛津英语词典,“iota”是“希腊字母I,ι的名称,对应于罗马的I,i;希腊字母表中最小的字母”(我认为是物理上最小的,而不是字母顺序),也意味着“最小或非常小的粒子或数量”。OED 对这个含义最早的已知用法来自Daniel Featley 在 1636 年的Clavis mystica:
Shall we lose, or sleightly pass by, any iota or tittle of the Booke of God?
我们是否会丢失或略过上帝之书的任何一点或一点?
Clavis mysticais a guide to parts of the Bible, 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:
Clavis mystica是圣经部分的指南,这句话特别指的是马太福音 5:18。1611 年版的国王詹姆士版本在马太福音 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.
因为我确实对你说,直到天地过去,一个小物或一个头衔,绝不会从法律中消失,直到一切都实现为止。
The OED gives “iote”?as another form of “jot”, which (like “iota”) descends from the Greek word “??τα”, which is the Greek name for the letter in question. Why did Featley change “iote” to “iota”? Sadly, I don't have a copy of Clavis mysticain my personal library, so I can't investigate that further.
OED 将“iote”作为“jot”的另一种形式,它(如“iota”)源自希腊词“??τα”,这是所讨论字母的希腊语名称。为什么 Featley 将“iote”改为“iota”?遗憾的是,我的个人图书馆中没有Clavis mystica的副本,因此我无法进一步调查。
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.
在马太福音 5:18 的希腊原文中,“iote”是“??τα”,“title”(或者更现代的,“title”)是“κερα?α”。“κερα?α”这个词的意思大致是“衬线”或“撇号”。所以这节圣经经文指的是最小细节的概念,并使用“??τα”来指代字母 iota 作为希腊字母表中物理上最小的字母。
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.
因此,我们可以推断出 STL 函数iota
及其 APL 前因?
,根据圣经,以希腊字母表中物理上最小的字母“ι”命名,因为这些函数产生的整数由整数可能的最小数量分隔分开。
According to Wikipedia, The Greek letter iota came from the Phoenician letter yōdh.
根据维基百科,希腊字母 iota 来自腓尼基字母 yōdh。
This is as far afield of programming as I currently wish to go for this question.
这是我目前希望解决这个问题的编程领域。
回答by patthoyts
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.
它的希腊字母有时在数学中被用来表示一组数字或单位向量。在 C++ 的情况下,你会得到一个构造的向量集。与itoa无关。
回答by Drew Dormann
std::iota
will fill an iterator range with successively incremented values.
std::iota
将用连续递增的值填充迭代器范围。
To answer your specific question, it actually doesn't stand for anything. Iota (pronounced "eye-oh-duh" in English)is a greek letter with mathematical connotations.
要回答您的具体问题,它实际上并不代表任何东西。Iota (英语发音为“eye-oh-duh”)是一个带有数学含义的希腊字母。
It is standard in C++11, but not in earlier standards.
它是 C++11 中的标准,但不是早期标准中的标准。
回答by einpoklum
Oh, I was always under the impression that since std::iota(start,end,0)
essentially stands for
哦,我一直觉得,既然std::iota(start,end,0)
本质上代表
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 分配给每个数组元素,而 iota 是希腊语中的 i,所以在那里。
(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.)
(如果这是@robmayoff 的回答中提到的 APL 选择的理由,我不会感到惊讶,尽管我不知道是否是这种情况。)
回答by jimifiki
I quote from this page: iotashamingwhere you can find more on the subject.
我引自此页面:iotashaming,您可以在其中找到有关该主题的更多信息。
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."
STL 深受肯·艾弗森 (Ken Iverson) 对 APL 的影响。在 1979 年肯的图灵奖演讲中,你会发现这句话:
“例如,由 ι 表示的整数函数产生前 N 个整数的向量。”