This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,31 @@
class Main
{
// multiply two matrices (with no error checking)
public static Int[][] multiply (Int[][] m1, Int[][] m2)
{
Int[][] result := [,]
m1.each |Int[] row1|
{
Int[] row := [,]
m2[0].size.times |Int colNumber|
{
Int value := 0
m2.each |Int[] row2, Int index|
{
value += row1[index] * row2[colNumber]
}
row.add (value)
}
result.add (row)
}
return result
}
public static Void main ()
{
m1 := [[1,2,3],[4,5,6]]
m2 := [[1,2],[3,4],[5,6]]
echo ("${m1} times ${m2} = ${multiply(m1,m2)}")
}
}