Skip to content

Commit 04c86cc

Browse files
committed
initial Range docs
1 parent 709d140 commit 04c86cc

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

lib/Range.pod

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
=begin pod
2+
3+
=head1 Range
4+
5+
class Range is Iterable does Positional { ... }
6+
7+
Ranges serve two main purposes: to generate lists of consecutive
8+
numbers or strings, and to act as a matcher to check if a number
9+
or string is within a certain range.
10+
11+
Ranges are constructed using one of the four possible range operators,
12+
which consist of two dots, and optionally a caret which indicates that
13+
the endpoint marked with it is excluded from the range.
14+
15+
1 .. 5
16+
1^.. 5 # start point excluded
17+
1 ..^5 # end point excluded
18+
1^..^5 # start and end point excluded
19+
20+
The caret is also a prefix operator for constructing numeric ranges
21+
starting from zero:
22+
23+
^$x # same as 0 ..^ $x.Numeric
24+
25+
Iterating a range (or calling the C<list> method) uses the same semantics as
26+
the C<++> prefix and postfix operators, ie it calls the C<succ> method on
27+
the start point, and then generated elements).
28+
29+
Ranges always go from small to larger elements; if the start point is bigger
30+
than the end point, the range is considered empty.
31+
32+
=head2 Methods
33+
34+
=head3 min
35+
36+
Returns the start point of the range
37+
38+
=head3 excludes_min
39+
40+
Returns C<True> if the start point is excluded from the range, and C<False>
41+
otherwise.
42+
43+
=head3 max
44+
45+
Returns the end point of the range
46+
47+
=head3 excludes_max
48+
49+
Returns C<True> if the end point is excluded from the range, and C<False>
50+
otherwise.
51+
52+
=head3 list
53+
54+
Generates the list of elements that the range represents.
55+
56+
=head3 flat
57+
58+
Generates the list of elements that the range represents.
59+
60+
=end pod

0 commit comments

Comments
 (0)