Problem 22

This commit is contained in:
2026-03-19 15:39:43 +01:00
parent b01ce98533
commit 96ab3811fa
2 changed files with 29 additions and 0 deletions
@@ -0,0 +1,14 @@
package ninetyNineScalaProblems
import scala.annotation.tailrec
object Problem22:
def range(start: Int, stop: Int): List[Any] =
@tailrec
def loop(cursor: Int, acc: List[Any]): List[Any] =
cursor match
case c if c <= stop =>
loop(cursor + 1, cursor :: acc)
case c if c > stop =>
acc
loop(start, List()).reverse