add


Number → Number → Number

Added in v0.1.0

Adds two values.

See also subtract.

  1. R.add(2, 3); //=> 5
  2. R.add(7)(10); //=> 17

divide


Number → Number → Number

Parameters

  • aThe first value.

  • bThe second value.

Returns Number The result of a / b.

Added in v0.1.0

Divides two numbers. Equivalent to a / b.

See also multiply.

  1. R.divide(71, 100); //=> 0.71
  2. const half = R.divide(R.__, 2);
  3. half(42); //=> 21
  4. const reciprocal = R.divide(1);
  5. reciprocal(4); //=> 0.25

multiply


Number → Number → Number

Parameters

  • aThe first value.
  • bThe second value.

Returns Number The result of a * b.

Added in v0.1.0

Multiplies two numbers. Equivalent to a * b but curried.

See also divide.

  1. const double = R.multiply(2);
  2. const triple = R.multiply(3);
  3. double(3); //=> 6
  4. triple(4); //=> 12
  5. R.multiply(2, 5); //=> 10

product


[Number] → Number

Parameters

  • listAn array of numbers

Returns Number The product of all the numbers in the list.

Added in v0.1.0

Multiplies together all the elements of a list.

See also reduce.

  1. R.product([2,4,6,8,100,1]); //=> 38400

subtract


Number → Number → Number

Parameters

  • aThe first value.
  • bThe second value.

Returns Number The result of a - b.

Added in v0.1.0

Subtracts its second argument from its first argument.

See also add.

  1. R.subtract(10, 8); //=> 2
  2. const minus5 = R.subtract(R.__, 5);
  3. minus5(17); //=> 12
  4. const complementaryAngle = R.subtract(90);
  5. complementaryAngle(30); //=> 60
  6. complementaryAngle(72); //=> 18

sum


[Number] → Number

Parameters

  • listAn array of numbers

Returns Number The sum of all the numbers in the list.

Added in v0.1.0

Adds together all the elements of a list.

See also reduce.

  1. R.sum([2,4,6,8,100,1]); //=> 121

modulo


Number → Number → Number

Parameters

  • aThe value to the divide.
  • bThe pseudo-modulus

Returns Number The result of b % a.

Added in v0.1.1

Divides the first parameter by the second and returns the remainder. Note that this function preserves the JavaScript-style behavior for modulo. For mathematical modulo see mathMod.

See also mathMod.

  1. R.modulo(17, 3); //=> 2
  2. // JS behavior:
  3. R.modulo(-17, 3); //=> -2
  4. R.modulo(17, -3); //=> 2
  5. const isOdd = R.modulo(R.__, 2);
  6. isOdd(42); //=> 0
  7. isOdd(21); //=> 1

mathMod


Number → Number → Number

Parameters

  • mThe dividend.
  • pthe modulus.

Returns Number The result of b mod a.

Added in v0.3.0

mathMod behaves like the modulo operator should mathematically, unlike the % operator (and by extension, R.modulo). So while -17 % 5 is -2, mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN when the modulus is zero or negative.

See also modulo.

  1. R.mathMod(-17, 5); //=> 3
  2. R.mathMod(17, 5); //=> 2
  3. R.mathMod(17, -5); //=> NaN
  4. R.mathMod(17, 0); //=> NaN
  5. R.mathMod(17.2, 5); //=> NaN
  6. R.mathMod(17, 5.3); //=> NaN
  7. const clock = R.mathMod(R.__, 12);
  8. clock(15); //=> 3
  9. clock(24); //=> 0
  10. const seventeenMod = R.mathMod(17);
  11. seventeenMod(3); //=> 2
  12. seventeenMod(4); //=> 1
  13. seventeenMod(10); //=> 7

de


Number → Number

Added in v0.9.0

Decrements its argument.

See also inc.

  1. R.dec(42); //=> 41

inc


Number → Number

Added in v0.9.0

Increments its argument.

See also dec.

  1. R.inc(42); //=> 43

negate


Number → Number

Added in v0.9.0

Negates its argument.

  1. R.negate(42); //=> -42