3 ms·
No actually I'm not completely grasping your argument. You described iteration earlier but I don't see any distinction with any definition of iteration I know o
by neonological 6y ago
No actually I'm not completely grasping your argument. You described iteration earlier but I don't see any distinction with any definition of iteration I know of.
I'm guessing your talking about how iteration is implemented versus the action of iteration. Both are one in the same.
- xapata 6y agoUsing a loop induction variable is a form of iteration over the elements of a sequence, but it is not using an iterator (technique, pattern, or whatever you want to call it). https://en.wikipedia.org/wiki/Induction_variable https://en.wikipedia.org/wiki/Induction_variable Heck, originally, looping was performed by physically looping your instruction tape, and a break was pausing the machine to physically break the tape. Talk about a fragile design pattern! The implementation matters. That's why people suggest using the iterator technique. It's not the best strategy for all cases, but it's generally better practice.
- neonological 6y agoThe index of a variable functions as an iterator for the iterator pattern. It still applies. There's not distinction here. But my point is also more general it doesn't apply to just iterators.
- xapata 6y agoScope matters. The purpose of the iterator is to encapsulate the state. An induction variable is not an iterator. A physical loop of tape is not an iterator. I'm starting to doubt your general point, because the specific isn't holding. Take a look at the Wikipedia page for iterators, under the heading "contrasting with indexing". It's not explained super-well, but it covers a few topics.
- neonological 6y ago>I'm starting to doubt your general point, because the specific isn't holding. A Very unwise and illogical notion to hold. We're addressing a very informal corner of CS that could be ripe with exceptions. Additionally the English language itself is full of grammatical inconsistencies so a single thing not holding does not disprove a generality. >Take a look at the Wikipedia page for iterators, under the heading "contrasting with indexing". It's not explained super-well, but it covers a few topics There's a contrast but nothing says this encapsulated state can't be an index itself. Meaning you can use indexes to implement iterators. As for the other point. The distinction between iterator and iteration. I still don't see it other than the fact that an iterator is used for iteration. From this page: https://en.wikipedia.org/wiki/Iteration https://en.wikipedia.org/wiki/Iteration "In Object-oriented programming, an iterator is an object that ensures iteration is executed in the same way for a range of different data structures, saving time and effort in later coding attempts. In particular, an iterator allows one to repeat the same kind of operation at each node of such a data structure, often in some pre-defined order. " Either way this is really an argument on semantics for a very narrow topic. The context is greater in scope and is about design patterns in general which I'm sure you'll agree doesn't encounter controversial collisions in meaning like iterator vs. iteration.