perl6/doc/lib/Iterator

doc src
(title) class Iterator
    class Iterator is Iterable { }

 
A Iterator is an object that can generate or provide elements of a sequence. Users usually don't have to care about iterators, their usage is hidden behind iteration APIs such as for @list { } , L<map>, L<grep> and list indexing with .[$idx] . Iterators provide an immutable view of a sequence, though the actual elements in the sequence can still be mutable.

Methods

(head2) reify
    method reify(Iterator:D: $n) returns Parcel:D

 
Returns at least $n elements of the sequence, followed by additional iterators needed to generate the remaining elements. Subsequent calls to reify on the same object must return the same L<Parcel>, even if $n changed between the calls.
(head2) infinite
    method infinite(Iterator:D:)

 
Returns True if the sequence being iterated is known to be infinite, False if it is known to be finite, and Mu if the iterator does not know if the sequence is finite or infinite.

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: