Ramda.js R.negate() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Ramda’s R.negate() takes a number and returns that number with the opposite sign. The official docs sample is a single call: R.negate(42) → -42. Added in v0.9.0.

Because it is a first-class function, you can drop it into pipelines instead of writing n => -n. Internally Ramda computes unary minus, so JavaScript’s -n rules apply — numeric strings coerce, and invalid values become NaN.

Syntax

Call R.negate. Start with this line.

Ramda
R.negate(n)
CallWhat it does
R.negate(n)Primary signature.
R.negate(...)Call the math helper.

Prefer import { negate } from "ramda" when you want a named import.

Library declarations
Ramda
R.negate(n)

Parameters

ParameterDescription
nRequired. the value to negate. Ramda computes -n.

Return Value

Return ValueDescription
*Returns -n. For real numbers that is a Number with the opposite sign.

Ramda Examples

📚 Getting Started

The official sign flip, then map it over a list.

Example 1 — The Official Docs Example

From ramdajs.com/docs/#negate: R.negate(42) returns -42.

Ramda
R.negate(42);   //=> -42
R.negate(-7);   //=> 7
R.negate(0);    //=> -0  (prints as 0)
R.negate(3.5);  //=> -3.5
Try It Yourself

How It Works

R.negate returns -n. With 42 that is -42 — the official sample. A negative becomes positive. Zero prints as 0 even though IEEE has a signed -0.

Example 2 — Point-Free Map and Double Negate

Pass R.negate to R.map — no arrow function needed. Two flips restore the original.

Ramda
R.map(R.negate, [1, -2, 3]);
//=> [-1, 2, -3]

R.negate(R.negate(42));
//=> 42
Try It Yourself

How It Works

R.map wants a one-argument function. R.negate already is one, so each list item flips sign. Applying negate twice is the identity for finite numbers.

📈 Practical Patterns

Compare to R.multiply(-1), flip an object field, and conditionally negate.

Example 3 — R.negate vs R.multiply(-1)

For real numbers they match. Unary minus also coerces numeric strings.

Ramda
R.negate(42);         //=> -42
R.multiply(-1, 42);   //=> -42
R.negate("10");       //=> -10
R.inc("10");          //=> "101"
Try It Yourself

How It Works

R.negate is implemented as -n. That is the same product as multiplying by -1 for ordinary numbers. Unlike R.inc("10"), which concatenates, R.negate("10") coerces the string first. Prefer real numbers anyway.

Example 4 — Flip an Object Field

R.evolve applies a function to a named property and returns a new object.

Ramda
var refund = { note: "credit", amount: 50 };

R.evolve({ amount: R.negate }, refund);
//=> { note: "credit", amount: -50 }
Try It Yourself

How It Works

R.evolve copies the object and runs R.negate on amount only. note is unchanged. The original refund object is not mutated.

Example 5 — Flip Positives Only with R.ifElse

Keep negatives and zero as they are. Negate only when the value is greater than zero.

Ramda
var flipIfPositive = R.ifElse(
  R.gt(R.__, 0),
  R.negate,
  R.identity
);

flipIfPositive(5);   //=> -5
flipIfPositive(-3);  //=> -3
flipIfPositive(0);   //=> 0
Try It Yourself

How It Works

R.gt(R.__, 0) is “is this greater than zero?” If yes, run R.negate. If no, R.identity returns the value unchanged. That is a tidy way to force non-positive numbers without touching values that are already negative.

Browser Support

R.negate() is plain JavaScript unary minus — 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.9.0+ · Any JS runtime

Ramda.js R.negate()

Load Ramda via CDN or npm, then call R.negate(n). Because it only uses unary minus, behavior is identical across engines.

100% With Ramda loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
R.negate() 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.negate(n) returns -n. It is Ramda's unary sign-flip helper — the functional equivalent of unary minus — so you can pass it to R.map, R.pipe, or R.evolve without writing a lambda.
R.negate(42) returns -42. That is the sample on ramdajs.com/docs/#negate. Added in v0.9.0.
Yes. It has arity 1 and is automatically curried. Call R.negate(42) for a number. Calling R.negate() with no argument returns a function that waits for n.
For real numbers they match: R.negate(42) and R.multiply(-1, 42) are both -42. R.negate is the dedicated unary helper, so it drops into R.map with no extra wrapping. R.multiply(-1) is a scaler you might reuse among other factors.
No. R.inc uses +, so R.inc("10") is "101". R.negate uses unary minus, which coerces: R.negate("10") is -10. Prefer real numbers anyway.
No. R.negate is a stable Ramda math helper from v0.9.0. It is not deprecated, experimental, or non-standard.

Continue to R.inc()

Learn plus-one next — another unary math helper that drops into R.map.

R.inc() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful