Skip to content

Commit e9f2f73

Browse files
committed
Iterator, Iterable (very incomplete)
1 parent a90f472 commit e9f2f73

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lib/Iterable.pod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=begin pod
2+
3+
=TITLE class Iterable
4+
5+
class Iterable is Cool { }
6+
7+
C<Iterable> serves as a superclass for objects that can be iterated with the
8+
C<for> construct and related iteration constructs.
9+
10+
C<Iterable> objects nested in other C<Iterable> objects (but not within scalar
11+
containers) flatten in certain contexts, for example when iterated with a
12+
C<for> loop, or on list assignment.
13+
14+
=end pod

lib/Iterator.pod

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
=begin pod
2+
3+
=TITLE class Iterator
4+
5+
class Iterator is Iterable { }
6+
7+
A C<Iterator> is an object that can generate or provide elements of a
8+
sequence. Users usually don't have to care about iterators, their usage
9+
is hidden behind iteration APIs such as C<for @list { }>, L<map>, L<grep>
10+
and list indexing with C<.[$idx]>.
11+
12+
Iterators provide an immutable view of a sequence, though the actual elements
13+
in the sequence can still be mutable.
14+
15+
=head1 Methods
16+
17+
=head2 reify
18+
19+
method reify(Iterator:D: $n) returns Parcel:D
20+
21+
Returns at least C<$n> elements of the sequence, followed by additional
22+
iterators needed to generate the remaining elements.
23+
24+
Subsequent calls to C<reify> on the same object must return the same
25+
L<Parcel>, even if C<$n> changed between the calls.
26+
27+
=head2 infinite
28+
29+
method infinite(Iterator:D:)
30+
31+
Returns C<True> if the sequence being iterated is known to be infinite,
32+
C<False> if it is known to be finite, and C<Mu> if the iterator does not know
33+
if the sequence is finite or infinite.
34+
35+
=end pod

0 commit comments

Comments
 (0)