RosettaCodeData/Task/Dot-product/Frink/dot-product.frink
2023-07-01 13:44:08 -04:00

10 lines
201 B
Text

dotProduct[v1, v2] :=
{
if length[v1] != length[v2]
{
println["dotProduct: vectors are of different lengths."]
return undef
}
return sum[map[{|c1,c2| c1 * c2}, zip[v1, v2]]]
}