Skip to content

Commit b26526f

Browse files
committed
Verbose explaination of the range operators.
Since, so far, pod tables cannot deal with C<>, I switched the table of range operators to a list of items with a specific code example following.
1 parent 5801be3 commit b26526f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

doc/Language/5to6-perlop.pod6

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,20 @@ In list context, C<..> operates as the range operator and should not
161161
need to be changed. That said, there are exclusionary range operators
162162
that may be useful. These are:
163163
164-
=begin table
164+
=item infix C<..^> which excludes the endpoint;
165+
=item infix ^.. which excludes the starting point;
166+
=item infix C<^..^> which excludes both the starting and ending points;
167+
=item prefix C<^> which starts from zero excluding the endpoint.
165168
166-
Mode Op Description
167-
====== ==== ============
168-
infix ..^ Excludes endpoint. C<1..^5>; # 1 2 3 4 >
169-
infix ^.. Excludes starting point. C<1^..5>; # 2 3 4 5>
170-
infix ^..^ Excludes both starting and endpoint. C<1^..^5>; # 2 3 4>
171-
prefix ^ From 0, excludes endpoint. C<^5>; # 0 1 2 3 4>
169+
The following example shows the effects of all the above range operators
170+
(please note parentheses are used only to allow the method call):
172171
173-
=end table
172+
=begin code
173+
(1..^5).list; # (1 2 3 4)
174+
(1^..5).list; # (2 3 4 5)
175+
(1^..^5).list; # (2 3 4)
176+
(^5).list; # (0 1 2 3 4)
177+
=end code
174178
175179
In scalar context, C<..> and C<...> work as flip-flop operators in Perl
176180
5, but are little-known, and probably even less used. Those operations

0 commit comments

Comments
 (0)