diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/vec.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/utils/vec.js b/utils/vec.js index 3996fc2..d595989 100644 --- a/utils/vec.js +++ b/utils/vec.js @@ -6,23 +6,29 @@ exports.mult = function(vec, scal){ return vec; } -function elem(orig, vec, op){ +exports.elem = function(orig, vec, op){ let comb = []; for (let i = 0; i < orig.length; i++){ comb.push(op(vec[i],orig[i])); } return comb; } -exports.elem = elem; + +exports.equals = function(orig, vec){ + for (let i = 0; i < orig.length; i++){ + if (orig[i] != vec[i]) return false; + } + return true; +} exports.add = function(orig, vec){ - return elem(orig, vec, (a,b) => a+b); + return exports.elem(orig, vec, (a,b) => a+b); } exports.sub = function(orig, vec){ - return elem(orig, vec, (a,b) => a-b); + return exports.elem(orig, vec, (a,b) => a-b); } exports.dot = function(orig,vec){ - return elem(orig, vec, (a,b) => a*b); + return exports.elem(orig, vec, (a,b) => a*b); } exports.tileToChar = function(orig){ return exports.dot(orig, [8,16]); |