Skip to content

Commit bb7d63e

Browse files
committed
Indexes flattening semicolon
Also adds examples. Closes #2379.
1 parent 86dca71 commit bb7d63e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

doc/Language/subscripts.pod6

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ elements and dimensions.
339339
say @twodim[0,1;1]; # 2nd element of both lists
340340
# OUTPUT: «(b 2)␤»
341341
342-
Multidimensional subscripts can be used to flatten nested lists.
342+
X<|; (flattening)>
343+
344+
Multidimensional subscripts can be used to flatten nested lists when combined
345+
with L<Whatever>.
343346
344347
my @toomany = [[<a b>], [1, 2]];
345348
say @toomany;
@@ -348,6 +351,16 @@ Multidimensional subscripts can be used to flatten nested lists.
348351
say @toomany[*;*];
349352
# OUTPUT: «(a b 1 2)␤»
350353
354+
You can use as many I<flattening semicolons> as you want; there will be, at
355+
most, as many nesting levels flattened as the number of semicolons:
356+
357+
say [[1,2,[3,4]],[4,5]][*;*]; # OUTPUT: «(1 2 [3 4] 4 5)␤»
358+
say [[1,2,[3,4]],[4,5]][*;*;*;*]; # OUTPUT: «(1 2 3 4 4 5)␤»
359+
360+
In the first example, with one C<Whatever> less than the number of levels, the
361+
deepest one will not be flattened; in the second case it is, since it's greater
362+
than the number of levels.
363+
351364
You can use L<Whatever|/type/Whatever> to select ranges or "rows" in
352365
multidimensional subscripts.
353366

0 commit comments

Comments
 (0)