• Jump To … +
    Either.js List.js Maybe.js Set.js Stream.js Thunk.js Tuple.js boolean.js char.js base.js extra.js fold.js map.js zipWith.js collection.js control.js curried.js eq.js floating.js fractional.js function.js integral.js match.js num.js numeric.js object.js ord.js realfrac.js register.js string.js type.js nodash.js
  • num.js

  • ¶
    /* vim: set et sw=2 ts=2: */
    'use strict';
    
    module.exports = {
    
      '+ add ADD plus PLUS': function (a, b) {
        return a + b;
      },
    
      '- minus MINUS': function (a, b) {
        return a - b;
      },
    
      'sub subtract': function (a, b) {
        return b - a;
      },
    
      '* mul MUL times TIMES': function (a, b) {
        return a * b;
      },
    
      abs: Math.abs,
    
      negate: function (x) {
        return -x;
      },
    
      signum: function (x) {
        if (x > 0) {
          return 1;
        } else if (x === 0) {
          return 0;
        }
        return -1;
      }
      
    };