Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def loop(in: List[Int], acc: Int): Int =
- in match {
- case Nil => acc // 終了条件
- case head :: tail =>
- val result = head * 2 // headのタスク
- loop(tail, acc + result) // 残りのリストと計算途中を渡して処理を継続
- }
- val result = loop((1 to 10).toList, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement