是“迭代”吗?或“迭代”某物?

发布于 2024-08-30 20:43:07 字数 1722 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(17

蓝梦月影 2024-09-06 20:43:07

“through”和“over”是无用的副词。

示例:

  • <块引用>

    迭代此集合时,我的代码抛出错误。

  • <块引用>

    此代码迭代集合。

  • <块引用>

    您的任务是编写迭代集合的代码。

这就像说“北上”或“南下”。 “上”和“下”是没有用的。相反,你应该说:“我要去北方过夏天。”或“在南方,他们种植棉花。”

"through" and "over" are useless adverbs.

Examples:

  • While iterating this collection, my code throws an error.

  • This code iterates the collection.

  • Your assignment is to write code that iterates the collection.

It's like saying "up north" or "down south". "up" and "down" are useless. Instead you should say, "I am going north for the summer." or "In the south, they grow cotton."

飘然心甜 2024-09-06 20:43:07

没有对错之分,只是一些统计数据:

= term =           = Google =   = Github =
"iterate over"      1,440,000   10,569,846 search results
"iterate through"     908,000    5,605,973
"iterate thru"         44,200      141,982
——————————————————————————————————————————
"iterate on"          402,000      187,576
"iterate in"           63,300      117,962
"iterate across"       10,900      208,342
"iterate within"        8,470       14,577
"iterate along"         8,060        6,396
"iterate among"         5,970        2,960
"iterate against"       2,580        3,255
"iterate inside"        2,450       35,060
"iterate amongst"         406       22,274
"iterate amidst"           66            0


Google 统计数据于 2018 年 4 月 25 日更新。后续搜索显示结果不稳定。
Github 统计数据于 2018 年 4 月 25 日更新。仅计算代码出现次数。

Not right or wrong, just some stats:

= term =           = Google =   = Github =
"iterate over"      1,440,000   10,569,846 search results
"iterate through"     908,000    5,605,973
"iterate thru"         44,200      141,982
——————————————————————————————————————————
"iterate on"          402,000      187,576
"iterate in"           63,300      117,962
"iterate across"       10,900      208,342
"iterate within"        8,470       14,577
"iterate along"         8,060        6,396
"iterate among"         5,970        2,960
"iterate against"       2,580        3,255
"iterate inside"        2,450       35,060
"iterate amongst"         406       22,274
"iterate amidst"           66            0


Google stats updated on 4/25/2018. Subsequent searches show that results are unstable.
Github stats updated on 4/25/2018. Only code occurrences are counted.

葬花如无物 2024-09-06 20:43:07

我认为这取决于介词的宾语;你遍历迭代器,遍历集合,遍历容器,遍历列表,遍历范围等,但是你遍历列表(的内容),遍历容器(的元素),遍历(的元素) )范围,通过集合(的元素)等。在几乎所有情况下,它们都是可以互换的;我唯一会使用“over”而不是“through”的地方是关于迭代器本身;但对于任何可迭代对象,我会使用“over”或“through”。

I think it depends on the object of the preposition; you iterate over the iterator, over the collection, over the container, over the list, over the range, etc. but you iterate through (the contents of) the list, through (the elements of) the container, through the (elements of ) the range, through (the elements of) the collection, etc. In almost all cases they are interchangeable; the only place I would use "over" but not "through" is with respect to the iterator, itself; but for any iterable object, I'd use either "over" or "through".

煮酒 2024-09-06 20:43:07

我会说迭代,这是我一直看到的编写方式。

I would say iterate over, and this is the way I've always seen it written.

尐籹人 2024-09-06 20:43:07

两者本质上意思是一样的!

因此,您可以自由选择适合您的。

Both essentially mean the same!

So, you are free to choose whichever suits you.

故事和酒 2024-09-06 20:43:07

我总是说“迭代over”,因为它强调了一个(相对重要的)事实,即迭代器本身不包含在作为迭代主题的容器中。

对我来说,说“迭代”意味着依次查看容器的每个元素,但这并不是真正发生的情况。

相反,“迭代”对我来说意味着依次接收容器中每个元素的外部句柄,这实际上就是正在发生的事情。

然而,“迭代”并没有什么问题,任何理解迭代器的人都一定会理解这两个短语。

I would always say "iterate over" because it emphasizes the (relatively important) fact that the iterators themselves are not contained in the container that is the subject of the iteration.

To say "iterate through", to me, would imply that one were looking at each element of the container in turn, which is not really what is happening.

In contrast, saying "iterate over" implies to me that one is receiving an external handle to each element of the container in turn, which is really what is happening.

However, there's nothing wrong with "iterate through", and anyone who understands iterators would surely understand both phrases.

睫毛上残留的泪 2024-09-06 20:43:07

从技术上讲,这可能只是“迭代”时期。但无论哪种情况,你的意思都很明显。

Technically it's probably just "iterate" period. But its obvious what you mean in either case.

淑女气质 2024-09-06 20:43:07

我使用“循环”。简单的。

I use "loop over". Simple.

GRAY°灰色天空 2024-09-06 20:43:07

System.Collections.Generic.IEnumerator GetEnumerator() 的摘要文本表示:

返回一个枚举器
迭代集合。

就我个人而言,我说通过......但实际上我认为您使用哪一个并不重要。

The summary text for System.Collections.Generic.IEnumerator GetEnumerator() says:

Returns an enumerator that
iterates through the collection.

Personally I say through ... but really I don't think it matters which one you use.

一世旳自豪 2024-09-06 20:43:07

重要的是迭代,你用什么填充物并不重要。

The important word is iterate, what filler you place with it really doesn't matter.

初雪 2024-09-06 20:43:07

我想象“迭代”某些东西,就像我做文件柜一样。也许这只是个人喜好,考虑到我的心理形象 - 我认为“迭代”是更常见的用法。

I picture "iterating through" something, the way I do a file cabinet. Maybe it's just personal preference though, given my mental image - I think "Iterate Over" is the more common usage.

残月升风 2024-09-06 20:43:07

我随机使用两者,有时在同一个句子中使用。删除连接词是一种糟糕的语法,而且没有任何意义。

I use both at random, sometimes in the same sentence. Dropping the connecting word is bad grammar and neither is meaningful.

伏妖词 2024-09-06 20:43:07

我认为它们在大多数实际用途中是可以互换的,但在我的评论中,我个人倾向于使用它们,但有一个小小的区别:我将“迭代”某些东西解释为类似于你会说“我会查看它”的意思”。也就是说,这不是一次深入的检查:您正在浏览它以寻找某些东西。相反,“迭代”就是有目的地遍历每一项。

因此,如果我只是在列表中搜索一个项目,我会说我正在“迭代”列表......如果我对每个项目应用一些转换,那么它将是“迭代”。

I think they are interchangeable for most practical purposes, but in my comments I personally tend to use them with a small distinction: I interpret to "iterate over" something to be similar to the sense that you would say "I'll look over it". That is, it's not a deep inspection: you are browsing over it looking for something. Conversely, to "iterate through" is to go through each and every one purposefully.

So if I was just searching for one item in a list I would say I was "iterating over" the list.....if I was applying some transformation to each item, it would be "iterate through".

满天都是小星星 2024-09-06 20:43:07

字典说“迭代”是一个及物动词,意思是“再说一遍或做一次;重复”。

你会“重复”刚刚说过的话,还是“重复”一遍吗?我认为你只需重复一遍即可。或者只是简单地迭代它,如您所愿。

话虽如此,如果您使用“迭代”作为“循环”的某种同义词......一次一次迭代地循环数据,那么也许您正在“迭代”。这是一个雷区!

Dictionary says "iterate" is a transitive verb meaning to "say or do again; repeat".

Would you "repeat over" something you just said, or "repeat through" it? I think you'd just plain repeat it. Or just plain iterate it, as you prefer.

Having said that, if you're using "iterate" as some kind of synonym for "loop"... looping through data one iteration at a time, perhaps, then maybe you ARE "iterating through". This is a minefield!

放赐 2024-09-06 20:43:07

两者都是修辞性的同义反复。你应该删除多余的介词。如在

“此循环迭代前 10 个产品”

或者,也许

“我正在迭代寻找可以接受的答案”

Either is a rhetoical tautology. You should remove the superfluous preposition. As in

"This loop iterates the top 10 products"

or, perhaps

"I am iterating the answers looking for the one to accept"

情何以堪。 2024-09-06 20:43:07

Common Lisp 的 LOOP 宏使用 for list 中的元素,但 for element across array (这是不同的,因此编译器可以生成更高效的代码......是的,这很奇怪),建议介词并不是那么重要。

Common Lisp's LOOP macro uses for element in list, but for element across array (it's different so the compiler can generate more efficient code ... yeah, it's weird), suggesting that the preposition isn't really that important.

如果没结果 2024-09-06 20:43:07

有一个更好的方法。

J's members are dissimilar, but all can be incremented.
Having incremented every member of 'J' ...
J contains incrementable elements.
J refers to several items.
J refrances several items.
Everything in J is incrementable.
Everything J refers to should necessarily be thought of as being storable in a set.
Sequentially referring to J's contents ...
Apply between each element of J and R until all possible compatible pairs have been found.
Ask J using it's 'ask' function to sequentially apply addition between it's contents and return the result.

就像“has”这个词一样,它经常可以将整个句子简化为一个单词。

为什么不保持 iterate 进行迭代,就像这样 ->圆形、三角形、八边形、五边形、六边形。

There is a better way.

J's members are dissimilar, but all can be incremented.
Having incremented every member of 'J' ...
J contains incrementable elements.
J refers to several items.
J refrances several items.
Everything in J is incrementable.
Everything J refers to should necessarily be thought of as being storable in a set.
Sequentially referring to J's contents ...
Apply between each element of J and R until all possible compatible pairs have been found.
Ask J using it's 'ask' function to sequentially apply addition between it's contents and return the result.

It's like the word "has", that can so often reduce a whole sentance to a single word.

Why not keep iterate for iteration, like this -> circle, triangle, octagon, pentagon, hexagon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文