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