simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

not.js (1546B)


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