Advertisement
Guest User

Untitled

a guest
Oct 10th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.21 KB | None | 0 0
  1. def sumRows(rows: Array[Int][Int], total:Int) : Int = rows match {
  2.   case Nil => total
  3.   case (x:xs) => sumRow(xs, total + fold(0, +, x))
  4. }
  5.  
  6. def sum2dArray(arr:Array[Int][Int]) : Int = {
  7.   sumRows(arr, 0)
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement