【发布时间】:2014-08-03 07:01:45
【问题描述】:
def find(list: List[(Char,Int)]): List[(Char,Int)] = {
list match {
case List() => List()
case (z,y):: xs => ((for(i <- 1 to y) yield (z,i)).toList ::: find(xs).toList)
}
find(List(('a',5),('b',3))) // will return nothing at all
我简直无法理解为什么这样的函数会为给定的参数返回空值。它没有空的参数,所以这里可能是什么问题?
这可能是一个非常简单的问题,但我真的需要一双新的眼睛来帮助我调试这个问题,因为我根本无法发现我犯的愚蠢错误
【问题讨论】: