Skip to content

Instantly share code, notes, and snippets.

@gunungloli666
Last active August 29, 2015 13:56
Show Gist options
  • Save gunungloli666/8816308 to your computer and use it in GitHub Desktop.
Save gunungloli666/8816308 to your computer and use it in GitHub Desktop.
package org.fjr.test
object TestFor extends App {
val m: List[List[Int]] = List(
List(3, 4, 4),
List(3, 12, 56),
List(123, 3, 4))
val n: List[List[Int]] = List(List(12, 4, 55),
List(123, 4, 4), List(12, 345, 44))
prints(m)
prints(n)
val trn = List.transpose(n)
val result = for (i <- m) yield {
for (j <- trn) yield {
(0 /: List.map2(i, j)(_ * _))(_ + _)
}
}
prints(result)
def prints(rs: List[List[Int]]) = {
rs.foreach(b => {
b.foreach(b => print(b + " | "))
println
})
println
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment