16 lines
287 B
Text
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";
|
|
}
|
|
}
|