From 208cb05c74e94eb0c7edea0959662e18269cce9f Mon Sep 17 00:00:00 2001 From: d98762625 Date: Sun, 25 Mar 2018 17:03:05 +0100 Subject: [PATCH] reuse difference function for symmetric difference --- src/core/operations/SetOperations.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/core/operations/SetOperations.js b/src/core/operations/SetOperations.js index 4c37a588..f213d975 100644 --- a/src/core/operations/SetOperations.js +++ b/src/core/operations/SetOperations.js @@ -72,7 +72,7 @@ class SetOps { "Cartesian Product": this.runCartesianProduct, "Power Set": this.runPowerSet(itemDelimiter), }[operation] - .apply(null, sets.map(s => s.split(itemDelimiter))); + .apply(this, sets.map(s => s.split(itemDelimiter))); // Formatting issues due to the nested characteristics of power set. if (operation === "Power Set") { @@ -142,18 +142,8 @@ class SetOps { * @return {Object} */ runSymmetricDifference(a, b) { - - /** - * One-way difference function, formatted for mapping. - * @param {Object[]} refArray - */ - const getDifference = (refArray) => (item) => { - return refArray.indexOf(item) === -1; - }; - - return a - .filter(getDifference(b)) - .concat(b.filter(getDifference(a))); + return this.runSetDifference(a,b) + .concat(this.runSetDifference(b, a)); } /**