, , , , :
def countSteps(n: Int): Int = {
def countSteps2(steps: List[Int], acc: Int): Int =
steps match {
case Nil => acc
case head :: tail =>
val (n, s) = if (head < 0) (0, Nil)
else if (head == 0) (1, Nil)
else (0, List(head - 1, head - 2, head - 3))
countSteps2(s ::: tail, n + acc)
}
countSteps2(List(n),0)
}
countSteps2 , . , , , countSteps2.
, , head 0, 1, . countSteps2 , tail, , , , acc. countSteps2 ,
, , , acc , .