Don't allow multiplication of vectors of different sizes

This commit is contained in:
PaddiM8 2022-01-05 20:39:10 +01:00
parent 3c6f38c28a
commit 443a1876fb

View File

@ -696,6 +696,10 @@ impl KalkValue {
.collect(),
),
(KalkValue::Vector(values), KalkValue::Vector(values_rhs)) => {
if values.len() != values_rhs.len() {
return KalkValue::nan();
}
let mut sum = KalkValue::from(0f64);
for (value, value_rhs) in values.iter().zip(values_rhs) {
sum = sum.add_without_unit(&value.clone().mul_without_unit(value_rhs));