Ramda.js R.o() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

R.o(f, g) is a curried composition function that returns a unary function: it runs g first, then f, so R.o(f, g)(x) is f(g(x)) (official Ramda docs). The name comes from the math composition symbol ∘.

Stable since v0.24.0: R.o is not deprecated, experimental, or non-standard. It composes exactly two functions; for more, use R.compose or R.pipe.

Syntax

Call R.o. Start with this line.

Ramda
R.o(f, g)(x) or R.o(f, g, x)
CallWhat it does
R.o(f, g)(x) or R.o(f, g, x)Primary signature.
R.o(...)Call the function helper.

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

Library declarations
Ramda
R.o(f, g)(x) or R.o(f, g, x)

Parameters

ParameterDescription
fRequired. Outer function — runs second
gRequired. Inner function — runs first, gets one argument
xOptional. The value; omit it to get a reusable function

Return Value

Return ValueDescription
*A unary function (.length is 1)

Ramda Examples

Example 1 — Official Add, Then Multiply

Add 10, then multiply by 10 — the math sample from the Ramda docs.

Ramda
const addThenTimes10 = R.o(R.multiply(10), R.add(10));

console.log(addThenTimes10(-4)); // 60
Try It Yourself

How It Works

  1. Compose. R.o stores both functions and returns addThenTimes10; nothing runs yet.
  2. Right first. R.add(10) turns -4 into 6.
  3. Left second. R.multiply(10) turns 6 into 60.
  4. Read it backwards. The function written last runs first.

Example 2 — Official Yelling Greeting

Build a sentence from an object, then uppercase it.

Ramda
const classyGreeting = (name) =>
  "The name's " + name.last + ", " + name.first + " " + name.last;

const yellGreeting = R.o(R.toUpper, classyGreeting);

console.log(yellGreeting({ first: 'James', last: 'Bond' }));
// "THE NAME'S BOND, JAMES BOND"
Try It Yourself

How It Works

  1. Inner function. classyGreeting runs first and builds "The name's Bond, James Bond".
  2. Outer function. R.toUpper receives that string and uppercases it.
  3. Any function works. Your own arrow function can sit next to a Ramda helper.
  4. Reusable. yellGreeting can be called with any { first, last } object.

Example 3 — Three Ways to Call It

R.o is curried over f, g, and x, so you can pass them together or one at a time.

Ramda
console.log(R.o(R.inc, R.negate, 5));    // -4
console.log(R.o(R.inc, R.negate)(5));    // -4
console.log(R.o(R.inc)(R.negate)(5));    // -4
Try It Yourself

How It Works

  1. Same steps. R.negate(5) → -5, then R.inc(-5) → -4.
  2. All at once. R.o(f, g, x) runs immediately.
  3. Two then one. R.o(f, g) returns a function, which you call with 5.
  4. One at a time. Each call collects one more argument until all three are in.

Example 4 — Sum One Field of a List

Pull out every price, then add them up — a tiny reusable helper.

Ramda
const totalPrice = R.o(R.sum, R.pluck('price'));

const cart = [{ price: 5 }, { price: 12 }, { price: 8 }];

console.log(totalPrice(cart)); // 25
Try It Yourself

How It Works

  1. Inner step. R.pluck('price') turns the cart into [5, 12, 8].
  2. Outer step. R.sum adds the numbers → 25.
  3. Both are unary. pluck already has its key, so each step takes one value.
  4. Point-free. totalPrice never names its argument.

Example 5 — R.o vs R.compose

Both run right to left, but R.o passes only one argument to the right function.

Ramda
console.log(R.o(R.inc, Math.max)(1, 5, 3));       // 2
console.log(R.compose(R.inc, Math.max)(1, 5, 3)); // 6
Try It Yourself

How It Works

  1. R.o drops extras. Math.max receives only 1 → 1, then R.inc → 2.
  2. R.compose passes all. Math.max(1, 5, 3) → 5, then R.inc → 6.
  3. Why it matters. R.o is predictable for one-value data.
  4. Rule of thumb. Multi-argument first step → R.compose.

Browser & Runtime Support

R.o() is plain JavaScript inside Ramda 0.24.0+. It uses no browser API, so support depends only on loading Ramda.

✓ Ramda 0.24.0+ · Any JS runtime

Ramda.js R.o()

The UMD build (ramda.min.js) is compiled to ES5 syntax, so it runs in Chrome, Firefox, Safari, and Edge. Via npm it works in Node.js, Deno, and Bun with require or import.

100% With Ramda 0.24+ 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.o() Universal

Bottom line: Safe in any project with Ramda 0.24.0 or later (check with npm ls ramda). Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. These labs load [email protected].

Frequently Asked Questions

R.o(f, g) composes two functions right to left and returns a new unary function, so R.o(f, g)(x) is f(g(x)). The official sample R.o(R.multiply(10), R.add(10))(-4) returns 60.
Both compose right to left. R.o takes exactly two functions and the right one always receives only one argument. R.compose accepts any number of functions, and its rightmost function receives every argument you pass.
The name comes from the mathematical composition operator ∘, where (f ∘ g)(x) means f(g(x)). R.o(f, g) reads the same way: f after g.
Yes. R.o is curried over three arguments, so R.o(f, g, x), R.o(f, g)(x), and R.o(f)(g)(x) all return f(g(x)).
No. R.o(f, g, h) treats h as the data, not a third step. Nest it as R.o(f, R.o(g, h)) or use R.compose(f, g, h) or R.pipe(h, g, f) instead.
No. R.o has been a stable Ramda function helper since v0.24.0. It is not deprecated, experimental, or non-standard.

Next: R.of()

Wrap a value in a constructor, such as a single-item array.

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