Ramda’s R.subtract() subtracts its second argument from its first. It returns a - b, but curried. The official docs sample is R.subtract(10, 8) → 2. Added in v0.1.0. See also R.add.
Because subtraction is not commutative, the docs show both placeholder styles: R.subtract(R.__, 5) for “minus five,” and R.subtract(90) for “ninety minus this” (a complementary angle).
Syntax
Call R.subtract. Start with this line.
Ramda
R.subtract(a, b)
Call
What it does
R.subtract(a, b)
Primary signature.
R.subtract(...)
Call the math helper.
Prefer import { subtract } from "ramda" when you want a named import.
Library declarations
Ramda
R.subtract(a, b)
Parameters
Parameter
Description
a
Required. the minuend (the value you subtract from). First argument.
b
Required. the subtrahend (the amount you subtract). Second argument.
Return Value
Return Value
Description
*
Returns a Number: Number(a) - Number(b).
Ramda Examples
📚 Getting Started
The official 10 - 8 sample, then the official minus5 helper.
R.subtract returns a - b. 10 - 8 is 2 — the official sample. Swapping to 8 - 10 gives -2, which is why argument order matters.
Example 2 — Official minus5 with R.__
The docs build a reusable minus-five function by filling the subtrahend and waiting for the minuend.
Ramda
var minus5 = R.subtract(R.__, 5);
minus5(17); //=> 12
minus5(5); //=> 0
// Without the placeholder, R.subtract(5) waits for the second number:
R.subtract(5)(17); //=> 5 - 17 (not minus five)
R.__ says “skip this slot.” R.subtract(R.__, 5) stores the amount 5 and waits for a. Plain R.subtract(5) stores the minuend instead, so R.subtract(5)(17) is 5 - 17, not minus five.
📈 Practical Patterns
Official complementary angles, mapping a minus helper, and pairwise differences.
R.subtract(90) is a function that still needs b. Calling it with 30 computes 90 - 30, which is 60 — the official complementary-angle sample. Two angles that add to 90° are complementary; this helper finds the other one.
Example 4 — Point-Free Map with minus5
Drop the official minus5 helper into R.map to subtract 5 from every item.
R.zipWith calls R.subtract on each pair: 10-1, 20-5, 30-8. Unlike R.inc, which concatenates strings, R.subtract wraps both sides in Number() — so "10" - 8 is 2.
Compatibility
Browser Support
R.subtract() is plain JavaScript subtraction — it runs anywhere Ramda loads: every modern browser plus Node.js. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.1.0+ · Any JS runtime
Ramda.js R.subtract()
Load Ramda via CDN or npm, then call R.subtract(a, b). Because it only uses Number(a) - Number(b), behavior is identical across engines.
100%With Ramda loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
R.subtract()Universal
Bottom line: Safe in any project that includes Ramda. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node.
Frequently Asked Questions
R.subtract(a, b) returns a - b. It is Ramda's curried subtraction helper — the functional equivalent of the - operator — so it can be partially applied and dropped into point-free pipelines. Both arguments are wrapped in Number() first.
R.subtract(10, 8) returns 2. The docs also show const minus5 = R.subtract(R.__, 5) with minus5(17) returning 12, and const complementaryAngle = R.subtract(90) with complementaryAngle(30) returning 60. Added in v0.1.0. See also R.add.
Yes. R.subtract has arity 2 and is automatically curried, so R.subtract(10, 8) and R.subtract(10)(8) both return 2. Calling it with one argument returns a function that waits for the second number.
R.__ is Ramda's placeholder. R.subtract(R.__, 5) fills the second argument (the amount to subtract) and waits for the first. That is how the official minus5 helper works: minus5(17) is 17 - 5.
R.subtract returns a - b and is not commutative: R.subtract(10, 8) is 2, while R.subtract(8, 10) is -2. R.add returns a + b and does not care about order. Both wrap arguments in Number().
No. R.subtract is a stable Ramda math helper from v0.1.0. It is not deprecated, experimental, or non-standard.