Ramda.js R.curryN() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

R.curryN(length, fn) returns a curried equivalent of fn that waits for length arguments — not fn.length. Same call styles and R.__ gaps as R.curry, with an arity you choose. Part of Ramda Function since v0.5.0 (stable — not deprecated).

When to prefer it: Rest parameters (...args) and default parameters shrink fn.length. Name the arity with curryN so the helper waits for the right number of slots.

Syntax

Call R.curryN. Start with this line.

Ramda
R.curryN(length, fn)
CallWhat it does
R.curryN(length, fn)Primary signature.
R.curryN(...)Call the function helper.

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

Library declarations
Ramda
R.curryN(length, fn)

Parameters

ParameterDescription
lengthRequired. How many arguments to wait for
fnRequired. Function to wrap (any fn.length)

Return Value

Return ValueDescription
*Curried function with arity length

Ramda Examples

Example 1 — Official sumArgs

Wrap a rest-parameter adder with arity 4. Supply two numbers, then the third, then the fourth.

Ramda
const sumArgs = (...args) => R.sum(args);
const curriedAddFourNumbers = R.curryN(4, sumArgs);
const f = curriedAddFourNumbers(1, 2);
const g = f(3);

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

How It Works

  1. Rest arity. sumArgs.length is 0, so plain R.curry cannot wait for four numbers.
  2. Name the arity. curryN(4, sumArgs) waits for four slots anyway.
  3. Partial calls. (1, 2) then (3) leave one slot open.
  4. Final call. g(4) runs R.sum([1, 2, 3, 4]) → 10.

Example 2 — Four Equivalent Call Styles

If g is R.curryN(3, f), the docs list these groupings. All yield 6.

Ramda
const sumArgs = (...args) => R.sum(args);
const add3 = R.curryN(3, sumArgs);

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. Arity 3. curryN(3, …) waits for three real numbers.
  2. Flexible groups. Each call may fill one slot or several.
  3. Same end. When three arrive, sumArgs returns 6.
  4. Same as curry. Only the arity source differs — you named 3.

Example 3 — Gaps with R.__

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

Ramda
const sumArgs = (...args) => R.sum(args);
const add3 = R.curryN(3, sumArgs);
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 ≠ slot. R.__ holds a gap; it does not count toward arity.
  2. Fill later. add3(_, 2, 3) waits for the first number.
  3. Any position. Middle gaps and multi-step fills work the same as with R.curry.
  4. Result. Three real numbers → 6. See also R.__.

Example 4 — Rest Args Break R.curry

sumArgs.length is 0, so plain curry finishes too soon. curryN(4, …) waits correctly.

Ramda
const sumArgs = (...args) => R.sum(args);

console.log(sumArgs.length);
// → 0

try {
  R.curry(sumArgs)(1, 2)(3, 4);
} catch (err) {
  console.log(err.name);
}
// → TypeError

console.log(R.curryN(4, sumArgs)(1, 2)(3, 4));
// → 10
Try It Yourself

How It Works

  1. Length 0. Rest parameters report arity 0.
  2. Plain curry. The first call can return a number; chaining (3, 4) throws.
  3. curryN(4). You override arity so four slots are required.
  4. Success. (1, 2)(3, 4) → 10.

Example 5 — Fix Default Parameters

Defaults shrink fn.length to 2. Use curryN(3, …) when the third argument must wait.

Ramda
const add3 = (a, b, c = 2) => a + b + c;

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

console.log(R.curry(add3)(1)(2));
// → 5

console.log(R.curryN(3, add3)(1)(2)(7));
// → 10
Try It Yourself

How It Works

  1. Defaults ignored. (a, b, c = 2) has length 2.
  2. Plain curry. (1)(2) already runs as 1 + 2 + 2 → 5.
  3. curryN(3). Three slots are required before add3 runs.
  4. Third arg used. (1)(2)(7) → 10 (default never applied).

Browser & Runtime Support

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

✓ Stable · Ramda 0.5.0+

R.curryN()

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.5.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.curryN Ramda 0.5.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.curryN(length, fn) returns a curried equivalent of fn that waits for length arguments, not fn.length. You can supply arguments one at a time or in groups. The original function runs only when every named slot is present.
const sumArgs = (...args) => R.sum(args); const curriedAddFourNumbers = R.curryN(4, sumArgs); then f = curriedAddFourNumbers(1, 2), g = f(3), g(4) yields 10. Added in v0.5.0. See also R.curry.
R.curry reads fn.length. Rest parameters and default parameters shrink that count, so curry can finish too soon. R.curryN(n, fn) lets you name the arity. R.curry(fn) is effectively R.curryN(fn.length, fn).
No. If g is R.curryN(3, f), the docs list four equivalent styles: g(1)(2)(3), g(1)(2, 3), g(1, 2)(3), and g(1, 2, 3).
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).
No. R.curryN is a stable Ramda function helper from v0.5.0. It is not deprecated, experimental, or non-standard.

Next: R.descend()

Learn how to build a descending comparator for sorting.

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