Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala调试这个递归示例_Scala_Debugging - Fatal编程技术网

Scala调试这个递归示例

Scala调试这个递归示例,scala,debugging,Scala,Debugging,因此,println(xs)代码不会运行。我基本上想看看当xs1只是一个单元素数组时会发生什么。但是我该怎么做呢?我主要想看看这是不是一个单元素列表被解构成了一个单元素,xs1在下一个过程中类似于null或[] Scala有哪些调试器?我如何使用它们?为什么println(xs)不起作用?不将函数封装在括号中只是打字错误吗?(def append[T](xs:List[T],ys:List[T]):List[T]={println(xs);xs match{case List()=>ys;cas

因此,
println(xs)
代码不会运行。我基本上想看看当
xs1
只是一个单元素数组时会发生什么。但是我该怎么做呢?我主要想看看这是不是一个单元素列表被解构成了一个单元素,
xs1
在下一个过程中类似于
null
[]


Scala有哪些调试器?我如何使用它们?为什么
println(xs)
不起作用?

不将函数封装在括号中只是打字错误吗?(
def append[T](xs:List[T],ys:List[T]):List[T]={println(xs);xs match{case List()=>ys;case x::xs1=>x::append(xs1,ys)}
)应该可以工作。确保先编译append函数。使用scala REPL,这会有所帮助。
def append[T](xs: List[T], ys: List[T]): List[T] =
    println(xs)
    xs match {
        case List() => ys
        case x :: xs1 => x :: append(xs1, ys)
    }

append(List(1,2), List(3,4));