Ramda.js R.inc() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Ramda’s R.inc() takes a number and returns that number plus one. The official docs sample is a single call: R.inc(42) → 43. Added in v0.9.0. See also R.dec.

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

Syntax

Call R.inc. Start with this line.

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

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

Library declarations
Ramda
R.inc(n)

Parameters

ParameterDescription
nRequired. the value to increment. Ramda computes n + 1.

Return Value

Return ValueDescription
*Returns n + 1. For real numbers that is a Number.

Ramda Examples

📚 Getting Started

The official increment, then map it over a list.

Example 1 — The Official Docs Example

From ramdajs.com/docs/#inc: R.inc(42) returns 43.

Ramda
R.inc(42);  //=> 43
R.inc(1);   //=> 2
R.inc(0);   //=> 1
R.inc(-4);  //=> -3
Try It Yourself

How It Works

R.inc returns n + 1. With 42 that is 43 — the official sample. Zero becomes 1. Negatives move one step toward zero.

Example 2 — Point-Free Map

Pass R.inc to R.map — no arrow function needed.

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

R.pipe(R.inc, R.inc)(5);
//=> 7
Try It Yourself

How It Works

R.map wants a one-argument function. R.inc already is one, so each list item gains 1. R.pipe(R.inc, R.inc) adds 1 twice.

📈 Practical Patterns

String concatenation vs R.add, object fields, and the official ifElse count helper.

Example 3 — R.inc vs R.add on Strings

The + in R.inc concatenates strings. R.add wraps both sides in Number().

Ramda
R.inc("10");     //=> "101"  (string + 1)
R.add(1, "10");  //=> 11     (Number() first)
R.dec("10");     //=> 9      (subtraction coerces)
R.inc(null);     //=> 1      (null + 1)
Try It Yourself

How It Works

R.inc is implemented as n + 1, so a numeric string concatenates. R.add calls Number() on both arguments, which is why R.add(1, "10") is 11. Pass real numbers to R.inc when you can.

Example 4 — Increment an Object Field

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

Ramda
var player = { name: "moe", score: 10 };

R.evolve({ score: R.inc }, player);
//=> { name: "moe", score: 11 }
Try It Yourself

How It Works

R.evolve copies the object and runs R.inc on score only. name is unchanged. The original player object is not mutated.

Example 5 — Official ifElse Count Helper

Ramda’s ifElse docs use R.inc to bump an existing count, or start at 1 when the key is missing.

Ramda
var incCount = R.ifElse(
  R.has("count"),
  R.over(R.lensProp("count"), R.inc),
  R.assoc("count", 1)
);

incCount({ count: 1 });  //=> { count: 2 }
incCount({});            //=> { count: 1 }
Try It Yourself

How It Works

R.has("count") chooses the branch. If the key exists, R.over runs R.inc on that property. If it does not, R.assoc creates count: 1. That is the official ifElse sample built around R.inc.

Browser Support

R.inc() is plain JavaScript addition — 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.inc()

Load Ramda via CDN or npm, then call R.inc(n). Because it only uses n + 1, 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.inc() 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.inc(n) returns n + 1. It is Ramda's unary increment helper — the functional equivalent of adding one — so you can pass it to R.map, R.pipe, or R.evolve without writing a lambda.
R.inc(42) returns 43. That is the sample on ramdajs.com/docs/#inc. Added in v0.9.0. See also R.dec.
Yes. It has arity 1 and is automatically curried. Call R.inc(42) for a number. Calling R.inc() with no argument returns a function that waits for n.
R.inc(n) is n + 1. R.dec(n) is n - 1. Addition with + can concatenate (R.inc('10') is '101'). Subtraction coerces numeric strings to numbers (R.dec('10') is 9). Prefer real numbers, or use R.add(1, n) when you need Number() coercion.
R.add(a, b) is a curried binary helper that wraps both arguments in Number() before adding. R.inc(n) is always plus one and uses the + operator, so R.inc('10') concatenates while R.add(1, '10') returns 11.
No. R.inc is a stable Ramda math helper from v0.9.0. It is not deprecated, experimental, or non-standard.

Continue to R.dec()

Learn minus-one next — the official counterpart of R.inc.

R.dec() 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