Ramda.js R.flip() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Takes a function and returns a new curried function that calls the original with its first two arguments swapped: R.flip(f)(a, b, c) runs f(b, a, c). Every later argument stays where it was. Part of Ramda Function since v0.1.0 (stable — not deprecated).

Note: flip changes the order of a function’s parameters. To reverse the items of a list, use R.reverse.

Syntax

Call R.flip. Start with this line.

Ramda
R.flip(fn) → then call it with arguments Meaning R.flip(f)(a, b, c) = f(b, a, c)
CallWhat it does
R.flip(fn) → then call it with arguments Meaning R.flip(f)(a, b, c) = f(b, a, c)Primary signature.
R.flip(...)Call the function helper.

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

Library declarations
Ramda
R.flip(fn) → then call it with arguments Meaning R.flip(f)(a, b, c) = f(b, a, c)

Parameters

ParameterDescription
fnRequired. The function to call with its first two parameters reversed

Return Value

Return ValueDescription
*A new function, curried to fn.length, that returns whatever fn returns

Ramda Examples

Example 1 — Official mergeThree

Join three values into an array, then call the flipped version with the same arguments.

Ramda
const mergeThree = (a, b, c) => [].concat(a, b, c);

mergeThree(1, 2, 3);
// → [1, 2, 3]

R.flip(mergeThree)(1, 2, 3);
// → [2, 1, 3]
Try It Yourself

How It Works

  1. Normal call. mergeThree(1, 2, 3) joins the values in order → [1, 2, 3].
  2. Wrap. R.flip(mergeThree) returns a new function; nothing runs yet.
  3. Swap. Calling it with (1, 2, 3) makes Ramda run mergeThree(2, 1, 3).
  4. Result. [2, 1, 3] — only the first two values traded places.

Example 2 — Curried Calls

The flipped function keeps the original arity, so you can supply arguments in any grouping.

Ramda
const mergeThree = (a, b, c) => [].concat(a, b, c);
const flipped = R.flip(mergeThree);

flipped(1, 2, 3);   // → [2, 1, 3]
flipped(1)(2)(3);   // → [2, 1, 3]
flipped(1, 2)(3);   // → [2, 1, 3]
Try It Yourself

How It Works

  1. Arity. mergeThree.length is 3, so the flipped function waits for three values.
  2. Collect. Each partial call stores arguments until all three have arrived.
  3. Swap once. When the third value arrives, slots 0 and 1 swap and mergeThree runs.
  4. Same answer. All three call styles produce [2, 1, 3].

Example 3 — Subtract From Every Number

R.subtract(a, b) means a - b. Flip it to build a “minus 10” helper for R.map.

Ramda
R.subtract(10, 3);           // → 7
R.flip(R.subtract)(10, 3);   // → -7

const minus10 = R.flip(R.subtract)(10);
R.map(minus10, [15, 20, 25]);
// → [5, 10, 15]
Try It Yourself

How It Works

  1. Normal. R.subtract(10, 3) is 10 - 3 → 7.
  2. Flipped. R.flip(R.subtract)(10, 3) runs R.subtract(3, 10) → -7.
  3. Partial. R.flip(R.subtract)(10) locks 10 as the amount to take away and waits for the number.
  4. Map. Each item becomes item - 10 → [5, 10, 15].

Example 4 — Add a Suffix to Every Word

R.concat(a, b) puts a first. Flip it so the mapped word comes first and "!" goes last.

Ramda
R.concat("hi", "!");   // → "hi!"

const exclaim = R.flip(R.concat)("!");
R.map(exclaim, ["hi", "ok"]);
// → ["hi!", "ok!"]
Try It Yourself

How It Works

  1. Problem. R.concat("!") would prefix each word ("!hi").
  2. Flip. R.flip(R.concat)("!") keeps "!" for the second slot.
  3. Map. R.map supplies each word, so Ramda runs R.concat(word, "!").
  4. Result. ["hi!", "ok!"] — a reusable suffix helper.

Example 5 — R.flip vs R.__

Both can delay the first argument. Pick the one that reads best for your case.

Ramda
R.flip(R.subtract)(10)(3);   // → -7
R.subtract(R.__, 10)(3);     // → -7
Try It Yourself

How It Works

  1. flip. 10 fills the flipped first slot, which becomes subtract’s second argument.
  2. R.__. The placeholder leaves slot one empty and puts 10 in slot two directly.
  3. Same math. Both end as R.subtract(3, 10) → -7.
  4. Rule. Use R.__ for a one-off hole; use R.flip for a reusable swapped helper.

Browser & Runtime Support

R.flip is a Ramda Function helper since v0.1.0, so every Ramda release includes it. 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.flip()

Pure JavaScript with no browser APIs. Works in evergreen browsers and current Node.js LTS once Ramda is loaded.

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.flip Ramda 0.1.0+

Bottom line: Safe for production in any project that uses Ramda. These labs load [email protected] from a CDN. Official reference: ramdajs.com/docs/#flip.

Frequently Asked Questions

R.flip(fn) returns a new curried function that calls fn with its first two arguments swapped. R.flip(f)(a, b, c) runs f(b, a, c). Later arguments keep their order. Added in v0.1.0.

Next: R.flow()

Pass a starting value through a list of unary functions, left to right.

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

11 people found this page helpful