Reputation: 612
I am having trouble trying to apply a map function to an Array with NumericRange.
val x: Array[NumericRange[Double]] = Array(-100.0 to 100.0 by 1.0)
val m = x.map(_ * theta1)
However, I am getting an error for this. :13: error: value * is not a member of scala.collection.immutable.NumericRange[Double] val m = x.map(_ * theta1)
So I understand that a NumericRange doesn't have a map function but what is an idiomatic way of doing it where I can apply a range and convert it to an array?
Upvotes: 0
Views: 552
Reputation: 9734
When you do x.map(_ * theta1)
you are trying to multiply NumericRange
itself by theta1, I guess you need
val m: Array[NumericRange[Double]] = x.map(_.map(_ * theta1))
with types:
val m: Array[NumericRange[Double]] = x.map(range: NumericRange[Double] => range.map(_ * theta1))
Upvotes: 1