@@ -145,48 +145,6 @@ sealed class NumericRange[T](
145
145
else head
146
146
} else super .max(ord)
147
147
148
- // Motivated by the desire for Double ranges with BigDecimal precision,
149
- // we need some way to map a Range and get another Range. This can't be
150
- // done in any fully general way because Ranges are not arbitrary
151
- // sequences but step-valued, so we have a custom method only we can call
152
- // which we promise to use responsibly.
153
- //
154
- // The point of it all is that
155
- //
156
- // 0.0 to 1.0 by 0.1
157
- //
158
- // should result in
159
- //
160
- // NumericRange[Double](0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0)
161
- //
162
- // and not
163
- //
164
- // NumericRange[Double](0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6000000000000001, 0.7000000000000001, 0.8, 0.9)
165
- //
166
- // or perhaps more importantly,
167
- //
168
- // (0.1 to 0.3 by 0.1 contains 0.3) == true
169
- //
170
- private [immutable] def mapRange [A ](fm : T => A )(implicit unum : Integral [A ]): NumericRange [A ] = {
171
- val self = this
172
-
173
- // XXX This may be incomplete.
174
- new NumericRange [A ](fm(start), fm(end), fm(step), isInclusive) {
175
-
176
- private [this ] lazy val underlyingRange : NumericRange [T ] = self
177
- override def foreach [@ specialized(Unit ) U ](f : A => U ): Unit = { underlyingRange foreach (x => f(fm(x))) }
178
- override def isEmpty = underlyingRange.isEmpty
179
- override def apply (idx : Int ): A = fm(underlyingRange(idx))
180
- override def containsTyped (el : A ) = underlyingRange exists (x => fm(x) == el)
181
-
182
- override def toString = {
183
- def simpleOf (x : Any ): String = x.getClass.getName.split(" \\ ." ).last
184
- val stepped = simpleOf(underlyingRange.step)
185
- s " ${super .toString} (using $underlyingRange of $stepped) "
186
- }
187
- }
188
- }
189
-
190
148
// a well-typed contains method.
191
149
def containsTyped (x : T ): Boolean =
192
150
isWithinBoundaries(x) && (((x - start) % step) == zero)
0 commit comments