简体   繁体   English

Scala,类型找不到参数n的隐式值

[英]Scala, Type could not find implicit value for parameter n

import Numeric._
import grizzled.math.stats._

val l = List[Double](123.0, 133.0, 155.0, 166.0, 177.0)
println(median(l))

Above you see an example which describes the usage of the package grizzled.math.stats at scala grizzled doc . 以上你看到它描述了包的使用为例grizzled.math.stats斯卡拉头发斑白的文档 I am not able to reproduce this simple example. 我无法重现这个简单的例子。

I always get following errors: 我总是收到以下错误:

  • could not find implicit value for parameter n: Numeric[Array[Double]] 找不到参数n的隐式值:Numeric [Array [Double]]
  • not enough arguments for method median: (implicit n: Numeric[Array[Double]])Double. 方法中位数的参数不足:(隐含n:Numeric [Array [Double]])Double。 Unspecified value parameter n. 未指定的值参数n。

Any suggestion to resolve this compilation error is welcome. 欢迎提供解决此编译错误的任何建议。 Thank you in advance. 先感谢您。

median expects a var-arg argument. median需要一个var-arg参数。 You could expand the list with _* syntax, like this: 您可以使用_*语法扩展列表,如下所示:

import Numeric._
import grizzled.math.stats._

val l = List[Double](123.0, 133.0, 155.0, 166.0, 177.0)
println(median(l: _*))

This compiles and outputs 155.0. 这将编译并输出155.0。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Scala编译错误-找不到类型为证据的隐式值 - Scala compile error - could not find implicit value for evidence parameter of type Scala类型参数化,Shapeless-找不到参数Generic的隐式值 - Scala type parameterization, Shapeless - could not find implicit value for parameter Generic Scala错误无法找到参数的隐式值 - Scala error Could not find implicit value for parameter 在Scala中找不到参数的隐式值 - Could not find implicit value for parameter in scala 在scala检查中为运行时类型启用隐式导入。 “找不到参数的隐式值” - enable implicit import for runtime type in scala check. “could not find implicit value for parameter” 无法找到类型证据参数的隐式值 - Could not find implicit value for evidence parameter of type 找不到类型^的证据参数的隐含值 - could not find implicit value for evidence parameter of type ^ 斯卡拉<console> :24: 错误: 找不到微风.storage.DefaultArrayValue [Any] 类型的证据参数的隐式值 - Scala <console>:24: error: could not find implicit value for evidence parameter of type breeze.storage.DefaultArrayValue[Any] Scala / specs2:找不到 AsExecution[ExecutionEnv =&gt; MatchResult[Future[AuthenticationResult]]] 类型的证据参数的隐式值 - Scala / specs2 : could not find implicit value for evidence parameter of type AsExecution[ExecutionEnv => MatchResult[Future[AuthenticationResult]]] 找不到scala.reflect.ClassManifest [T]类型的证据参数的隐式值 - Could not find implicit value for evidence parameter of type scala.reflect.ClassManifest[T]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM