Ramda.js R.add() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Ramda’s R.add() takes two values and returns their sum. On its own that sounds like the humble + operator — but because Ramda functions are automatically curried, R.add can be handed just one argument to produce a brand-new function that adds that number to whatever comes next.

That currying is what makes R.add shine in functional pipelines. Instead of writing x => x + 1, you can write R.add(1) and feed it directly to R.map or R.pipe. Internally Ramda computes Number(a) + Number(b), so numeric strings are coerced before they are added.

Syntax

Call R.add. Start with this line.

Ramda
R.add(a, b)
CallWhat it does
R.add(a, b)Primary signature.
R.add(...)Call the math helper.

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

Library declarations
Ramda
R.add(a, b)

Parameters

ParameterDescription
aRequired. the first value to add. Coerced with Number(a).
bRequired. the second value to add. Coerced with Number(b).

Return Value

Return ValueDescription
*Returns a Number: the sum Number(a) + Number(b).

Ramda Examples

📚 Getting Started

Add two numbers and use Ramda’s automatic currying.

Example 1 — Add Two Numbers

The classic Ramda intro: pass both operands and get their sum back.

Ramda
R.add(2, 3);   //=> 5
R.add(-4, 10); //=> 6
R.add(1.5, 2); //=> 3.5
Try It Yourself

How It Works

R.add simply returns a + b (after numeric coercion). With both arguments supplied, it evaluates immediately — no currying step is needed.

Example 2 — Partial Application (Currying)

Supply one argument to build a reusable adder — the heart of why Ramda exposes + as a function.

Ramda
const add7 = R.add(7);

add7(10);      //=> 17
add7(100);     //=> 107
R.add(7)(10);  //=> 17 (same as add7(10))
Try It Yourself

How It Works

Because R.add has arity 2 and is curried, calling it with one number returns a function that remembers that number. add7 then adds 7 to any value you give it later.

📈 Practical Patterns

Coercion behavior, point-free mapping, and list totals.

Example 3 — Numeric Coercion

Unlike the raw + operator, Ramda coerces both arguments with Number(), so numeric strings add up instead of concatenating.

Ramda
R.add('1', '2');   //=> 3   (not '12')
R.add('10', 5);    //=> 15
R.add('foo', 1);   //=> NaN (cannot coerce)

// Compare with the + operator:
'1' + '2';         //=> '12'
Try It Yourself

How It Works

Ramda computes Number('1') + Number('2'), which is 1 + 2 = 3. A value like 'foo' becomes NaN under Number(), and any arithmetic with NaN stays NaN.

Example 4 — Point-Free Increment with R.map

Drop a partial adder straight into R.map to transform every element — no arrow function needed.

Ramda
const inc = R.add(1);

R.map(inc, [1, 2, 3]);        //=> [2, 3, 4]
R.map(R.add(10), [1, 2, 3]);  //=> [11, 12, 13]
Try It Yourself

How It Works

R.add(1) is a one-argument function, exactly the shape R.map wants. Ramda calls it once per element, adding 1 (or 10) to each value.

Example 5 — Total a List with R.reduce

R.add makes a perfect reducer. For a quick total you can also use R.sum.

Ramda
const prices = [10, 20, 30];

R.reduce(R.add, 0, prices); //=> 60

// Shortcut for the same total:
R.sum(prices);              //=> 60
Try It Yourself

How It Works

R.reduce threads an accumulator through the list, calling R.add(acc, item) each step. Starting from 0, it produces 0+10+20+30 = 60 — the same result R.sum gives in one call.

Browser & Runtime Support

R.add() is plain JavaScript arithmetic — it runs anywhere Ramda loads: every modern browser plus Node.js, Deno, and Bun. Ramda has no runtime dependencies.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.add()

Load Ramda via CDN or npm, then call R.add. Because it only uses Number() and +, behavior is identical across engines.

100% With Ramda loaded
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
R.add() 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.add(a, b) returns the sum of two values. It is Ramda's curried addition helper — the functional equivalent of the + operator — so it can be partially applied and dropped into point-free pipelines.
Yes. R.add has arity 2 and is automatically curried, so R.add(7, 10) and R.add(7)(10) both return 17. Calling it with one argument returns a new function that waits for the second number.
Yes. Internally Ramda computes Number(a) + Number(b), so numeric strings are converted before adding: R.add('1', '2') is 3, not '12'. Values that cannot be coerced (like 'foo') produce NaN.
R.add adds exactly two values, while R.sum adds every number in a list: R.sum([1, 2, 3]) is 6. Use R.add with R.reduce when you need finer control over the accumulation.
R.add returns a + b; R.subtract returns a - b. Both are curried binary math helpers. Note that R.subtract is not commutative, so argument order matters more there.
Yes. R.add(1) returns a function that adds one to whatever you pass it — the same idea as R.inc. R.map(R.add(1), [1, 2, 3]) yields [2, 3, 4].

Continue to R.subtract()

Learn how Ramda handles subtraction with the same curried, point-free style.

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