1 | 'use strict';
|
2 |
|
3 | var flatten = require('../../utils/array').flatten;
|
4 |
|
5 | function factory(type, config, load, typed) {
|
6 | var MatrixIndex = load(require('../../type/matrix/MatrixIndex'));
|
7 | var concat = load(require('../matrix/concat'));
|
8 | var size = load(require('../matrix/size'));
|
9 | var subset = load(require('../matrix/subset'));
|
10 | var setDifference = load(require('../set/setDifference'));
|
11 |
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | var setSymDifference = typed('setSymDifference', {
|
34 | 'Array | Matrix, Array | Matrix': function ArrayMatrixArrayMatrix(a1, a2) {
|
35 | if (subset(size(a1), new MatrixIndex(0)) === 0) {
|
36 |
|
37 | return flatten(a2);
|
38 | } else if (subset(size(a2), new MatrixIndex(0)) === 0) {
|
39 | return flatten(a1);
|
40 | }
|
41 | var b1 = flatten(a1);
|
42 | var b2 = flatten(a2);
|
43 | return concat(setDifference(b1, b2), setDifference(b2, b1));
|
44 | }
|
45 | });
|
46 |
|
47 | return setSymDifference;
|
48 | }
|
49 |
|
50 | exports.name = 'setSymDifference';
|
51 | exports.factory = factory; |
\ | No newline at end of file |