Iterators: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: Expand verbiage a bit, contrast explicit iterators with object slice notation)
Line 241: Line 241:


=={{header|Raku}}==
=={{header|Raku}}==
Raku has iterators, but is rare for casual users to ever expilcity use them. Operators and functions that are designed to work on Iterable objects generally have the iteration semantics built in; so don't need an iterator to be explicitly called. It is far, '''far''' more common to use object slices to do the task example operations.
Raku has iterators, but is rare for casual users to ever explicitly use them. Operators and functions that are designed to work on Iterable objects generally have the iteration semantics built in; so don't need an iterator to be explicitly called. It is far, '''far''' more common to use object slices to do the task example operations.


Rakus iterators are one direction only (not reversible), since they are designed to be able to work with infinite streams. It is difficult to reverse a stream that has no end. If the object / collection is finite, it may be reversed, but that is a separate operation from iteration.
Rakus iterators are one direction only (not reversible), since they are designed to be able to work with infinite streams. It is difficult to reverse a stream that has no end. If the object / collection is finite, it may be reversed, but that is a separate operation from iteration.