0
votes
Seq.range[Double](.0, 1.0 + step, step).foreach(current_degree_of_freedom => { ... }

(with step a Double).

The full error is :

Error:(39, 26) could not find implicit value for evidence parameter of type Integral[Double] Seq.range[Double](.0, 1.0 + step, step).foreach(current_degree_of_freedom => {

I have read the ScalaDoc ( http://www.scala-lang.org/api/2.12.3/scala/collection/Seq$.html#rangeT(implicitevidence$2:Integral[T]):CC[T] ), the problem comes from the 2nd curryied list of parameter.

But I don't understand the error... I thought it could be due to the absence of [Double] just after Seq.range, so I wrote it but it didn't solve the problem...

Anyone can explain me the problem please ?

2

2 Answers

2
votes

When you pass in Double values to the range method, the compiler will look for an implicit Integral[Double]. Apparently you're not providing this implicit value, hence the error. To make the compiler happy, add an implicit Integral[Double]:

implicit val integralD = scala.math.Numeric.DoubleAsIfIntegral

val range = Seq.range(0.0, 1.2, 0.2)
// List(0.0, 0.2, 0.4, 0.6000000000000001, 0.8, 1.0)
1
votes

Do you need Seq? Scala has a very rich type structure.

Your type is probably NumericRange and there is a natural way to generate the sequence of numbers you want to work with. Check the result type of this

val mynumrange = 0.0 to 1.0 by step