RosettaCodeData/Task/Dot-product/Rascal/dot-product-1.rascal
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

16 lines
287 B
Text

import List;
public int dotProduct(list[int] L, list[int] M){
result = 0;
if(size(L) == size(M)) {
while(size(L) >= 1) {
result += (head(L) * head(M));
L = tail(L);
M = tail(M);
}
return result;
}
else {
throw "vector sizes must match";
}
}