Ramda.js R.curry() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

R.curry(fn) returns a curried equivalent of fn. You can pass arguments one at a time, in groups, or all at once — and skip slots with R.__. Part of Ramda Function since v0.1.0 (stable — not deprecated).

Warning: Default parameters do not count toward fn.length, so curry may wait for fewer arguments than you expect. Prefer R.curryN when you must set arity yourself.

Syntax

Call R.curry. Start with this line.

Ramda
R.curry(fn)
CallWhat it does
R.curry(fn)Primary signature.
R.curry(...)Call the function helper.

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

Library declarations
Ramda
R.curry(fn)

Parameters

ParameterDescription
fnRequired. Function to curry; arity from fn.length

Return Value

Return ValueDescription
*Curried function (also accepts R.__ gaps)

Ramda Examples

Example 1 — Official addFourNumbers

Wrap a four-argument adder, supply two numbers, then the third, then the fourth.

Ramda
const addFourNumbers = (a, b, c, d) => a + b + c + d;
const curriedAddFourNumbers = R.curry(addFourNumbers);
const f = curriedAddFourNumbers(1, 2);
const g = f(3);

console.log(g(4));
// → 10
Try It Yourself

How It Works

  1. Arity. addFourNumbers.length is 4, so curry waits for four numbers.
  2. First call. (1, 2) fills two slots → f still needs two more.
  3. Second call. f(3) fills one more → g needs one.
  4. Final call. g(4) runs 1 + 2 + 3 + 4 → 10.

Example 2 — Four Equivalent Call Styles

The docs list these groupings for a ternary. All four yield the same sum.

Ramda
const add3 = R.curry((a, b, c) => a + b + c);

console.log(add3(1)(2)(3));
// → 6

console.log(add3(1)(2, 3));
// → 6

console.log(add3(1, 2)(3));
// → 6

console.log(add3(1, 2, 3));
// → 6
Try It Yourself

How It Works

  1. No forced unary calls. Each invocation may fill one slot or several.
  2. Same target. All styles wait until three numbers arrive.
  3. Then run. The original adder returns 6 every time.
  4. Pick what fits. Use one-at-a-time in pipelines; pass groups when you already have them.

Example 3 — Gaps with R.__

Skip a slot and fill it later. The docs alias the placeholder as _.

Ramda
const add3 = R.curry((a, b, c) => a + b + c);
const _ = R.__;

console.log(add3(_, 2, 3)(1));
// → 6

console.log(add3(1, _, 3)(2));
// → 6

console.log(add3(_, 2)(1, 3));
// → 6
Try It Yourself

How It Works

  1. Placeholder ≠ argument. R.__ holds a gap; it does not count toward arity.
  2. Fill later. add3(_, 2, 3) waits for the first number.
  3. Any position. You can skip the middle slot or leave several gaps.
  4. Same result. Once three real numbers exist, the sum is 6. See also R.__.

Example 4 — Default Parameters Break Curry

Defaults shrink fn.length. After two arguments the result is already a number, so a third call throws.

Ramda
const h = R.curry((a, b, c = 2) => a + b + c);

console.log(h.length);
// → 2

console.log(h(1)(2));
// → 5

try {
  h(1)(2)(7);
} catch (err) {
  console.log(err.name);
}
// → TypeError
Try It Yourself

How It Works

  1. Length lies. (a, b, c = 2) has length 2, so curry waits for two args only.
  2. Early result. h(1)(2) runs as 1 + 2 + 2 → 5.
  3. Third call fails. 5(7) throws — the docs say “3 is not a function.”
  4. Fix. Use R.curryN(3, fn) when you need three slots.

Example 5 — Curry vs a Plain Function

JavaScript does not curry for you. volume(2)(3)(4) fails until you wrap it.

Ramda
function volume(l, w, h) {
  return l * w * h;
}

try {
  volume(2)(3)(4);
} catch (err) {
  console.log(err.name);
}
// → TypeError

console.log(R.curry(volume)(2)(3)(4));
// → 24
Try It Yourself

How It Works

  1. Plain call. volume(2) returns a number (NaN with missing args), not a function.
  2. Chain breaks. Calling that result again throws TypeError.
  3. Curry wraps. R.curry(volume) waits for three numbers across calls.
  4. Result. (2)(3)(4) → 2 * 3 * 4 = 24.

Browser & Runtime Support

R.curry is a Ramda Function helper since v0.1.0. It runs anywhere Ramda runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install ramda.

✓ Stable · Ramda 0.1.0+

R.curry()

Available in [email protected] full builds once the library is loaded. Works in evergreen browsers and current Node LTS when Ramda is installed. No extra browser API is required.

100% With Ramda 0.1.0+
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.curry Ramda 0.1.0+

Bottom line: Safe for production once Ramda is loaded (CDN or npm). Prefer a modular build if you tree-shake. IE and very old engines are fine only if your Ramda bundle targets them.

Frequently Asked Questions

R.curry(fn) returns a curried equivalent of fn. You can supply arguments one at a time or in groups. The original function runs only when every required argument is present. Arity comes from fn.length.
const addFourNumbers = (a, b, c, d) => a + b + c + d; const curriedAddFourNumbers = R.curry(addFourNumbers); then f = curriedAddFourNumbers(1, 2), g = f(3), g(4) yields 10. Added in v0.1.0. See also R.curryN and R.partial.
No. For a ternary g the docs list four equivalent styles: g(1)(2)(3), g(1)(2, 3), g(1, 2)(3), and g(1, 2, 3). Mix groups until the arity is full.
R.__ is a placeholder that leaves a gap so you can fill a later argument first. If g is a curried ternary, g(R.__, 2, 3)(1) equals g(1, 2, 3).
Default parameters do not count toward fn.length. R.curry((a, b, c = 2) => a + b + c) waits for only two arguments. h(1)(2) already returns a number, so h(1)(2)(7) throws. Use R.curryN when you must set the arity yourself.
No. R.curry is a stable Ramda function helper from v0.1.0. It is not deprecated, experimental, or non-standard.

Next: R.curryN()

Learn how to curry with an explicit arity when fn.length is wrong.

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

12 people found this page helpful