1 | 'use strict';
|
2 |
|
3 | function factory(type, config, load, typed) {
|
4 | var combinations = load(require('../probability/combinations'));
|
5 | var add = load(require('../arithmetic/addScalar'));
|
6 | var isPositive = load(require('../utils/isPositive'));
|
7 | var isInteger = load(require('../utils/isInteger'));
|
8 | var larger = load(require('../relational/larger'));
|
9 |
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | var composition = typed('composition', {
|
33 | 'number | BigNumber, number | BigNumber': function numberBigNumberNumberBigNumber(n, k) {
|
34 | if (!isInteger(n) || !isPositive(n) || !isInteger(k) || !isPositive(k)) {
|
35 | throw new TypeError('Positive integer value expected in function composition');
|
36 | } else if (larger(k, n)) {
|
37 | throw new TypeError('k must be less than or equal to n in function composition');
|
38 | }
|
39 |
|
40 | return combinations(add(n, -1), add(k, -1));
|
41 | }
|
42 | });
|
43 |
|
44 | composition.toTex = undefined;
|
45 |
|
46 | return composition;
|
47 | }
|
48 |
|
49 | exports.name = 'composition';
|
50 | exports.factory = factory; |
\ | No newline at end of file |