Skip to content

Commit f8b3cde

Browse files
committed
doc multidim literal lists
1 parent eb7b786 commit f8b3cde

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

doc/Language/list.pod6

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,33 @@
66
77
Lists have been a central part of computing since before there
88
were computers, during which time many devils have taken up residence in
9-
their details. They were actually one of the hardest parts of Perl 6
9+
their details. They were actually one of the hardest parts of Perl 6
1010
to design, but through persistence and patience, Perl 6 has arrived with
1111
an elegant system for handling them.
1212
1313
=head1 Literal Lists
1414
15-
Literal L<C<List>s|/type/List> are created with commas B<not> with
16-
parentheses, so:
15+
Literal L<C<List>s|/type/List> are created with commas and semicolons B<not>
16+
with parentheses, so:
1717
1818
1, 2 # This is two-element list
19-
(1, 2) # This is also a list, in parentheses
20-
(1) # This is not a list, just a 1 in parentheses
21-
(1,) # This is a one-element list
19+
(1, 2) # This is also a List, in parentheses
20+
(1; 2) # same List
21+
(1) # This is not a List, just a 1 in parentheses
22+
(1,) # This is a one-element List
2223
23-
Parentheses can be used to mark the beginning and end of a list, so:
24+
Parentheses can be used to mark the beginning and end of a C<List>, so:
2425
2526
(1, 2), (1, 2) # This is a list of two lists.
2627
28+
Multidimensional literal C<List>s are created combining comma and semicolon.
29+
They can be used in routine argument lists and subscripts.
30+
31+
say so (1,2; 3,4) eqv ((1,2), (3,4));
32+
# OUTPUT«True␤»
33+
say('foo';); # a list with one element and the empty list
34+
# OUTPUT«(foo)()␤»
35+
2736
Individual elements can be pulled out of a list using a subscript. The
2837
first element of a list is at index number zero:
2938

0 commit comments

Comments
 (0)