RosettaCodeData/Task/Dot-product/Bc/dot-product.bc
2017-09-25 22:28:19 +02:00

19 lines
283 B
Text

/* Calculate the dot product of two vectors a and b (represented as
* arrays) of size n.
*/
define d(a[], b[], n) {
auto d, i
for (i = 0; i < n; i++) {
d += a[i] * b[i]
}
return(d)
}
a[0] = 1
a[1] = 3
a[2] = -5
b[0] = 4
b[1] = -2
b[2] = -1
d(a[], b[], 3)