소스 검색

reuse difference function for symmetric difference

d98762625 7 년 전
부모
커밋
208cb05c74
1개의 변경된 파일3개의 추가작업 그리고 13개의 파일을 삭제
  1. 3 13
      src/core/operations/SetOperations.js

+ 3 - 13
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));
     }
 
     /**