我遵循了Scala""功能编程的过程。在课程上。在第5周列表,讲座5.2,当试图构建一个List时,我得到&#34的错误;包列表不是值",代码如下:
package week5
object Test extends App{
def msort(x:List[Int]):List[Int] = {
val mid = x.length/2
if (mid == 0) x
else{
def merge(x:List[Int],y:List[Int]):List[Int] = (x, y) match {
case (Nil,y) =>y
case (x,Nil) =>x
case (x1::xs1, y1::ys1) =>{
if(x1 < y1) x1 :: merge(xs1,y)
else y1 :: merge(x, ys1)
}
}
val (fst,snd) = x.splitAt(mid)
val sfst = msort(fst)
val ssnd = msort(snd)
merge(sfst,ssnd)
}
}
val x = List(-4,2,5,-10,9,8,5) //error, Package list is not a value
val sx = msort(x)
}
有人知道这个问题吗?
的值