Clarified some wording on the zipper iterator. Changed the example to something more simple and informative.

This commit is contained in:
Ian Bertolacci 2015-08-02 14:35:41 -07:00
parent c2f85b27b5
commit 11ca1012e4

View File

@ -533,11 +533,13 @@ iter oddsThenEvens( N: int ): int {
for i in oddsThenEvens( 10 ) do write( i, ", " ); for i in oddsThenEvens( 10 ) do write( i, ", " );
writeln( ); writeln( );
// The 'zippered' iterator is an iterator that takes two or more iterators that // We can zipper together two or more iterators (who have the same number
// have the same number of iterations and zips them together into one stream // of iterations) using zip() to create a single zipped iterator, where each
// Ranges have implicit iterators // iteration of the zipped iterator yields a tuple of one value yielded
for (odd, even) in zip( 1..#10 by 2, 2..#10 by 2 ) do // from each iterator.
writeln( (odd, even) ); // Ranges have implicit iterators
for (positive, negative) in zip( 1..5, -5..-1) do
writeln( (positive, negative) );
// Classes are similar to those in C++ and Java. // Classes are similar to those in C++ and Java.
// They currently lack privatization // They currently lack privatization