1 | import { deepMap } from '../../utils/collection';
|
2 | import { factory } from '../../utils/factory';
|
3 | import { notNumber } from '../../plain/number';
|
4 | var name = 'not';
|
5 | var dependencies = ['typed'];
|
6 | export var createNot =
|
7 | /* #__PURE__ */
|
8 | factory(name, dependencies, function (_ref) {
|
9 | var typed = _ref.typed;
|
10 |
|
11 | /**
|
12 | * Logical `not`. Flips boolean value of a given parameter.
|
13 | * For matrices, the function is evaluated element wise.
|
14 | *
|
15 | * Syntax:
|
16 | *
|
17 | * math.not(x)
|
18 | *
|
19 | * Examples:
|
20 | *
|
21 | * math.not(2) // returns false
|
22 | * math.not(0) // returns true
|
23 | * math.not(true) // returns false
|
24 | *
|
25 | * a = [2, -7, 0]
|
26 | * math.not(a) // returns [false, false, true]
|
27 | *
|
28 | * See also:
|
29 | *
|
30 | * and, or, xor
|
31 | *
|
32 | * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check
|
33 | * @return {boolean | Array | Matrix}
|
34 | * Returns true when input is a zero or empty value.
|
35 | */
|
36 | var not = typed(name, {
|
37 | number: notNumber,
|
38 | Complex: function Complex(x) {
|
39 | return x.re === 0 && x.im === 0;
|
40 | },
|
41 | BigNumber: function BigNumber(x) {
|
42 | return x.isZero() || x.isNaN();
|
43 | },
|
44 | Unit: function Unit(x) {
|
45 | return x.value !== null ? not(x.value) : true;
|
46 | },
|
47 | 'Array | Matrix': function ArrayMatrix(x) {
|
48 | return deepMap(x, not);
|
49 | }
|
50 | });
|
51 | return not;
|
52 | }); |
\ | No newline at end of file |