Skip to content

Commit a7691be

Browse files
committed
Improves and fixes some errors in the lazy "lists" section
* Changes indexing * Changes the link to Iterator to a link to Iterable * Refers generically to objects, not specifically to lists. This refs #2139, but there's some more work to do. Including, possibly, moving the whole section to another page, such as Iterators.
1 parent 8e9251b commit a7691be

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

doc/Language/list.pod6

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,16 @@ value, but unlike the above options, it will break L<Scalars|/type/Scalar>.
229229
say (1, |$(2, 3), 4) eqv (1, 2, 3, 4); # OUTPUT: «True␤»
230230
say (1, slip($(2, 3)), 4) eqv (1, 2, 3, 4); # OUTPUT: «False␤»
231231
232-
=head1 Lazy Lists
233-
X<|lazy (property of List)>
234-
235-
Lists can be lazy, which means that their values are computed on demand and
236-
stored for later use. To create a lazy list use
237-
L<gather/take|/language/control#gather/take> or the L<sequence
238-
operator|/language/operators#infix_...>. You can also write a class that
239-
implements the role L<Iterable|/type/Iterable> and returns C<True> on a call to
240-
L<is-lazy|/routine/is-lazy>. Please note that some methods like C<elems> cannot
241-
be called on a lazy List and will result in a thrown
232+
X<|laziness in iterable objects>
233+
=head1 Lazy lists
234+
235+
Lists, arrays, sequences and any class with the L<Iterator> role can be lazy,
236+
which means that their values are computed on demand and stored for later use.
237+
To create a lazy object use L<gather/take|/language/control#gather/take> or the
238+
L<sequence operator|/language/operators#infix_...>. You can also write a class
239+
that implements the role L<Iterator|/type/Iterator> and returns C<True> on a
240+
call to L<is-lazy|/routine/is-lazy>. Please note that some methods like C<elems>
241+
cannot be called on a lazy List and will result in a thrown
242242
L<Exception|/type/Exception>.
243243
244244
# This list is lazy and elements will not be available
@@ -256,9 +256,10 @@ L<Exception|/type/Exception>.
256256
say @no-longer-lazy[];
257257
# OUTPUT: (sequence starting with «[1 11 121» ending with a 300 digit number)
258258
259-
A common use case for lazy Lists are the processing of infinite sequences of numbers,
260-
whose values have not been computed yet and cannot be computed in their entirety.
261-
Specific values in the List will only be computed when they are needed.
259+
A common use case for lazy C<List>s is the processing of infinite sequences of
260+
numbers, whose values have not been computed yet and cannot be computed in their
261+
entirety. Specific values in the List will only be computed when they are
262+
needed.
262263
263264
my @l = 1, 2, 4, 8 ... Inf;
264265
say @l[0..16];

0 commit comments

Comments
 (0)