1 | import { flatten } from '../../utils/array';
|
2 | import { factory } from '../../utils/factory';
|
3 | var name = 'setMultiplicity';
|
4 | var dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index'];
|
5 | export var createSetMultiplicity =
|
6 |
|
7 | factory(name, dependencies, function (_ref) {
|
8 | var typed = _ref.typed,
|
9 | size = _ref.size,
|
10 | subset = _ref.subset,
|
11 | compareNatural = _ref.compareNatural,
|
12 | Index = _ref.Index;
|
13 |
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | return typed(name, {
|
36 | 'number | BigNumber | Fraction | Complex, Array | Matrix': function numberBigNumberFractionComplexArrayMatrix(e, a) {
|
37 | if (subset(size(a), new Index(0)) === 0) {
|
38 |
|
39 | return 0;
|
40 | }
|
41 |
|
42 | var b = flatten(Array.isArray(a) ? a : a.toArray());
|
43 | var count = 0;
|
44 |
|
45 | for (var i = 0; i < b.length; i++) {
|
46 | if (compareNatural(b[i], e) === 0) {
|
47 | count++;
|
48 | }
|
49 | }
|
50 |
|
51 | return count;
|
52 | }
|
53 | });
|
54 | }); |
\ | No newline at end of file |