slight syntax corrections
This commit is contained in:
parent
3cd2a20498
commit
aa34ceeae4
@ -35,13 +35,13 @@ class vector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add(vec=new vector([...this.d.map(d => 0)]) {
|
add(vec=new vector([...this.d.map(d => 0)])) {
|
||||||
vec = vec instanceof vector ? vec : new vector([0]);
|
vec = vec instanceof vector ? vec : new vector([0]);
|
||||||
var longest = vec.d.length > this.d.length ? vec.d : this.d;
|
var longest = vec.d.length > this.d.length ? vec.d : this.d;
|
||||||
var shortest = vec.d.length < this.d.length ? vec.d : this.d;
|
var shortest = vec.d.length < this.d.length ? vec.d : this.d;
|
||||||
return new vector([...longest.map(function (value,index) {
|
return new vector([...longest.map(function (value,index) {
|
||||||
var small = shortest[index];
|
var small = shortest[index];
|
||||||
if !isNaN(small) { return value + small; } else { return value; }
|
if (!isNaN(small)) { return value + small; } else { return value; }
|
||||||
})]);
|
})]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class vector {
|
|||||||
var shortest = vec.d.length < this.d.length ? vec.d : this.d;
|
var shortest = vec.d.length < this.d.length ? vec.d : this.d;
|
||||||
return new vector([...longest.map(function (value,index) {
|
return new vector([...longest.map(function (value,index) {
|
||||||
var small = shortest[index];
|
var small = shortest[index];
|
||||||
if (!isNaN(small) { return value * small; } else { value; }
|
if (!isNaN(small)) { return value * small; } else { value; }
|
||||||
})]);
|
})]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user