def walk2(list2:List[Int],string:String):String={
println(s"list2= ${list2},string=${string}")
if(list2.isEmpty) string+"啊哈哈,变成空了吧"
else
walk2( list2.tail,string + list2.head + "JJ")
}
walk2(a,"")
这个能实现尾递归
println(s"list2= ${list2},string=${string}")
if(list2.isEmpty) string+"啊哈哈,变成空了吧"
else
walk2( list2.tail,string + list2.head + "JJ")
}
walk2(a,"")
这个能实现尾递归
2021-12-09