RosettaCodeData/Task/Dot-product/Fantom/dot-product.fantom
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

20 lines
332 B
Text

class DotProduct
{
static Int dotProduct (Int[] a, Int[] b)
{
Int result := 0
[a.size,b.size].min.times |i|
{
result += a[i] * b[i]
}
return result
}
public static Void main ()
{
Int[] x := [1,2,3,4]
Int[] y := [2,3,4]
echo ("Dot product of $x and $y is ${dotProduct(x, y)}")
}
}