【发布时间】:2016-06-13 18:15:32
【问题描述】:
我在 Scala 中重写了一系列 Haskell 函数,遇到了一个我似乎无法解释的编译错误
错误如下:
missing parameter type
def group[A](xs: List[A]): List[List[A]] = groupBy((a, b) => a == b, xs)
^
missing parameter type
def group[A](xs: List[A]): List[List[A]] = groupBy((a, b) => a == b, xs)
^
代码如下:
object Stuff {
def main(args: Array[String]): Unit = {
val lst = List(1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 5, 6, 7)
println(group(lst))
}
def group[A](xs: List[A]): List[List[A]] = groupBy((a, b) => a == b, xs)
def groupBy[A](fun: (A, A) => Boolean, input: List[A]): List[List[A]] = // stuff
}
我完全不确定这里发生了什么,为什么它抱怨缺少参数类型。据我所知,一切都已定义
【问题讨论】: