Problem 22

This commit is contained in:
jakob.scheid committed 2026-03-19 15:39:43 +01:00
1 parent b01ce98533
commit 96ab3811fa
2 files changed
+29

No files matched your search

@@ -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