SHARE
TWEET

Untitled

a guest Jul 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def loop(in: List[Int], acc: Int): Int =
  2.   in match {
  3.     case Nil => acc // 終了条件
  4.     case head :: tail =>
  5.       val result = head * 2 // headのタスク
  6.       loop(tail, acc + result) // 残りのリストと計算途中を渡して処理を継続
  7.   }
  8.  
  9. val result = loop((1 to 10).toList, 0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top