File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -363,12 +363,19 @@ very context sensitive on a syntactical level.
363
363
364
364
When a list appears on the right-hand side of an assignment into a C < @ > -sigiled
365
365
variable, it is "eagerly" evaluated. This means that a C < Seq > will be iterated
366
- until it can produce no more elements. This is one of the places you do not want
367
- to put an infinite list, lest your program hang and, eventually, run out of memory:
368
-
369
- my $i = 3;
370
- my @a = (loop { $i.say; last unless --$i }); # OUTPUT: «321»
371
- say "take off!";
366
+ until it can produce no more elements. This is one of the places you do not
367
+ want to put an infinite list, lest your program hang and, eventually, run out of
368
+ memory:
369
+
370
+ my @divisors = (gather {
371
+ for <2 3 5 7> {
372
+ take $_ if 70 %% $_;
373
+ }
374
+ });
375
+ say @divisors; # OUTPUT: «[2 5 7]»
376
+
377
+ The L < C < gather > statement\/language/control#index-entry-lazy_list_gather>
378
+ creates a lazy list, which is eagerly evaluated when assigned to C < @divisors >
372
379
373
380
= head2 Flattening "context"
374
381
You can’t perform that action at this time.
0 commit comments