Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
doc lazy lists
  • Loading branch information
gfldex committed Jul 8, 2016
1 parent da63e22 commit 03c49a9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Language/list.pod6
Expand Up @@ -145,6 +145,20 @@ value, but unlike the above options, it will break L<Scalars|/type/Scalar>.
say (1, |$(2, 3), 4) eqv (1, 2, 3, 4); # also says True
say (1, slip($(2, 3)), 4) eqv (1, 2, 3, 4); # says False
=head1 Lazy Lists
Lists can be lazy, what means that their values are computed on demand and
stored for later use. To create a lazy list use
L<gather/take|/language/control#gather/take> or the
L<sequence operator|/language/operators#infix_...>. You can also write a class that
implements the role L<Iterable|/type/Iterable> and returns C<True> on a call to
L<lazy|/routine/lazy>. Please note that some methods like C<elems> may cause the
entire list to be computed what will fail if the list is also infinite.
my @l = 1,2,4,8...Inf;
say @l[0..16];
# OUTPUT«(1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536)␤»
=head1 Immutability
The lists we have talked about so far (C<List>, C<Seq> and C<Slip>)
Expand Down

0 comments on commit 03c49a9

Please sign in to comment.