@@ -11,6 +11,19 @@ C<Seq> is born in a state where iterating it will consume the values.
11
11
Calling C < .cache > on a C < Seq > will make it store the generated values
12
12
for later access.
13
13
14
+ A high-level construct to generate a C < Seq > is L « C < gather/take > |/syntax/gather%20take» ,
15
+ as well as many built-in methods like L « C < map > |/routine/map» and
16
+ L « C < grep > |/routine/grep» , low-level constructors to create a
17
+ C < Seq > from an iterator or from looping constructs are available too.
18
+
19
+ A C < Seq > can also be constructed with the
20
+ L « sequence operator C < ... > |/language/operators#infix_... » or one of its
21
+ variants.
22
+
23
+ my $s = (1...5);
24
+ say $s; # OUTPUT: «1 2 3 4 5)»
25
+ say $s.^name; # OUTPUT: «Seq»
26
+
14
27
Assigning the values of a C < Seq > to an array consumes a C < Seq > that is
15
28
not lazy. Use the C < lazy > statement prefix to avoid a C < Seq > from being
16
29
iterated during the assignment:
@@ -49,9 +62,6 @@ it couldn't throw away old values), so this dies:
49
62
# (you might solve this by adding .cache on usages of the Seq, or
50
63
# by assigning the Seq into an array)»
51
64
52
- A high-level construct to generate a C < Seq > is C < gather/take > , as well as many
53
- built-in methods like C < map > and C < grep > , low-level constructors to create a
54
- C < Seq > from an iterator or from looping constructs are available too.
55
65
56
66
B < Caution: > No program should ever assume a C < Seq > may only be iterated once
57
67
even if not cached by the program. Caching is a volatile state exposed to the
0 commit comments