@@ -40,6 +40,11 @@ Use the C<...> sequence operator to produce lists of elements that
40
40
go from larger to smaller values, or to use offsets other than
41
41
increment-by-1.
42
42
43
+ Use C < Inf > or C < * > (Whatever) to indicate an end point to be open-ended.
44
+
45
+ for 1..* { .say } # start from 1, continue until stopped
46
+ for 1..Inf { .say } # the same
47
+
43
48
= head1 Methods
44
49
45
50
= head2 method min
@@ -74,6 +79,35 @@ otherwise.
74
79
75
80
Returns a list consisting of the start and end point.
76
81
82
+ = head2 method infinite
83
+
84
+ method infinite(Range:D:) returns Bool:D
85
+
86
+ Returns C < True > if either end point was declared with C < Inf > or C < * > .
87
+
88
+ = head2 method is-int
89
+
90
+ method is-int(Range:D:) returns Bool:D
91
+
92
+ Returns C < True > if both end points are C < Int > values.
93
+
94
+ = head2 method int-bounds
95
+
96
+ method bounds(Range:D:) returns Positional
97
+
98
+ If the C < Range > is an integer range (as indicated by L < is-int > , then this
99
+ method returns a list with the first and last value it will iterate over
100
+ (taking into account L < excludes-min > and L < excludes-max > ). Returns a
101
+ Failure If it is not an integer range.
102
+
103
+ = head2 method elems
104
+
105
+ method elems(Range:D:) returns Numeric:D
106
+
107
+ Returns the number of elements in the range, e.g. when being iterated over,
108
+ or when used as a C < List > . Returns Inf if either end point was specified
109
+ as C < Inf > or C < * > .
110
+
77
111
= head2 method list
78
112
79
113
method list(Range:D:) returns List:D
@@ -86,4 +120,20 @@ Generates the list of elements that the range represents.
86
120
87
121
Generates the list of elements that the range represents.
88
122
123
+ = head2 method pick
124
+
125
+ method pick(Range:D: ) returns Any:D
126
+ method pick(Range:D: $number) returns Seq:D
127
+
128
+ Performs the same function as C < Range.list.pick > , but attempts to optimize
129
+ by not actually generating the list if it is not necessary.
130
+
131
+ = head2 method roll
132
+
133
+ method roll(Range:D: ) returns Any:D
134
+ method roll(Range:D: $number) returns Seq:D
135
+
136
+ Performs the same function as C < Range.list.roll > , but attempts to optimize
137
+ by not actually generating the list if it is not necessary.
138
+
89
139
= end pod
0 commit comments