@@ -17,7 +17,7 @@ Arrays to have every value of the list stored in a container.
17
17
C < List > implements C < Positional > and as such provides support for
18
18
L < subscripts|/language/subscripts > .
19
19
20
- = head1 Items, Flattening and Sigils
20
+ = head1 Items, flattening and sigils
21
21
22
22
In Perl 6, assigning a C < List > to a scalar variable does not lose information.
23
23
The difference is that iteration generally treats a list (or any other list-like
@@ -64,7 +64,7 @@ operation such as C<append>:
64
64
65
65
my @d = <a b>;
66
66
@d.append: $a; # The array variable @d has 3 elements, because
67
- # $a is in an item context and as far as append is
67
+ # $a is in and as far as append is
68
68
# concerned a single element
69
69
70
70
say @d.elems; # OUTPUT: «3»
@@ -109,11 +109,12 @@ Defined as:
109
109
110
110
multi method ACCEPTS(List:D: $topic)
111
111
112
- If C < $topic > is an L < Iterable|/type/Iterable > , returns C < True > or C < False > based on
113
- whether the contents of the two C < Iterables > match. A L < Whatever|/type/Whatever >
114
- element in the invocant matches anything in the corresponding position
115
- of the C < $topic > C < Iterable > . A L < HyperWhatever|/type/HyperWhatever > matches any number of
116
- any elements, including no elements:
112
+ If C < $topic > is an L < Iterable|/type/Iterable > , returns C < True > or C < False > based
113
+ on whether the contents of the two C < Iterables > match. A
114
+ L < Whatever|/type/Whatever > element in the invocant matches anything in the
115
+ corresponding position of the C < $topic > C < Iterable > . A
116
+ L < HyperWhatever|/type/HyperWhatever > matches any number of any elements,
117
+ including no elements:
117
118
118
119
say (1, 2, 3) ~~ (1, *, 3); # OUTPUT: «True»
119
120
say (1, 2, 3) ~~ (9, *, 5); # OUTPUT: «False»
@@ -129,9 +130,9 @@ In addition, returns C<False> if either the invocant or C<$topic>
129
130
L < is a lazy|/routine/is-lazy > C < Iterable > , unless C < $topic > is the same object
130
131
as the invocant, in which case C < True > is returned.
131
132
132
- If C < $topic > is I < not > an L < Iterable|/type/Iterable > , returns the invocant if the invocant
133
- has no elements or its first element is a L < Match|/type/Match > object (this behavior
134
- powers C < m:g// > smartmatch), or C < False > otherwise.
133
+ If C < $topic > is I < not > an L < Iterable|/type/Iterable > , returns the invocant if
134
+ the invocant has no elements or its first element is a L < Match|/type/Match >
135
+ object (this behavior powers C < m:g// > smartmatch), or C < False > otherwise.
135
136
136
137
= head2 routine elems
137
138
@@ -275,8 +276,9 @@ Invokes C<&code> for each element and gathers the return values in a
275
276
sequence and returns it. This happens lazily, i.e. C < &code > is only
276
277
invoked when the return values are accessed.Examples:
277
278
278
- say ('hello', 1, 22/7, 42, 'world').map: { .^name } # OUTPUT: «(Str Int Rat Int Str)»
279
- say map *.Str.chars, 'hello', 1, 22/7, 42, 'world'; # OUTPUT: «(5 1 8 2 5)»
279
+ = for code
280
+ say ('hello', 1, 22/7, 42, 'world').map: { .^name } # OUTPUT: «(Str Int Rat Int Str)»
281
+ say map *.Str.chars, 'hello', 1, 22/7, 42, 'world'; # OUTPUT: «(5 1 8 2 5)»
280
282
281
283
C < map > inspects the arity of the code object, and tries to pass as many
282
284
arguments to it as expected:
0 commit comments