Ramda.js R.adjust() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.adjust(idx, fn, list) applies fn to the item at index idx and returns a new copy of the list with that one item replaced (official Ramda docs). The original list is never changed, negative indexes count from the end, and an out-of-range index returns the list as-is.

Stable since v0.14.0: R.adjust is not deprecated, experimental, or non-standard. Heads-up: since v0.26.0 the order is (idx, fn, list) — older tutorials put fn first.

Syntax

Call R.adjust. Start with this line.

Ramda
R.adjust(idx, fn, list)
CallWhat it does
R.adjust(idx, fn, list)Primary signature.
R.adjust(...)Call the list helper.

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

Library declarations
Ramda
R.adjust(idx, fn, list)

Parameters

ParameterDescription
idxRequired. Whole-number index; negative counts from the end
fnRequired. Receives the current item, returns its replacement
listRequired. Array (or array-like) to read from — never mutated

Return Value

Return ValueDescription
*A new array, or the original list if idx is out of range

Ramda Examples

Example 1 — Official Index 1 and -1

Uppercase the second letter, then the last one — the samples from the Ramda docs.

Ramda
const letters = ['a', 'b', 'c', 'd'];

console.log(R.adjust(1, R.toUpper, letters));  // ['a', 'B', 'c', 'd']
console.log(R.adjust(-1, R.toUpper, letters)); // ['a', 'b', 'c', 'D']
Try It Yourself

How It Works

  1. Find the slot. Index 1 is 'b' (slots start at 0).
  2. Transform it. R.toUpper('b') → 'B' goes into a new copy.
  3. Count from the end. -1 becomes (4 + -1) % 4 = 3 → 'd' → 'D'.
  4. Same idea as at(). Negative positions work like Array.at(-1).

Example 2 — Out of Range Returns the Original

No error and no copy: an index outside the list gives back the very same array.

Ramda
const letters = ['a', 'b', 'c', 'd'];

console.log(R.adjust(4, R.toUpper, letters));  // ['a', 'b', 'c', 'd']
console.log(R.adjust(-5, R.toUpper, letters)); // ['a', 'b', 'c', 'd']
console.log(R.adjust(4, R.toUpper, letters) === letters); // true
Try It Yourself

How It Works

  1. Valid range. For 4 items, indexes -4 to 3 are allowed.
  2. Too high. 4 fails the check, so the list comes back unchanged.
  3. Too low. -5 also fails — same result.
  4. Same reference. === letters is true: Ramda skipped the copy and never called R.toUpper.

Example 3 — The Original Array Stays Untouched

R.adjust returns a new array; your input keeps its old values.

Ramda
const nums = [1, 2, 3];
const result = R.adjust(0, R.multiply(10), nums);

console.log(result);          // [10, 2, 3]
console.log(nums);            // [1, 2, 3]
console.log(result === nums); // false
Try It Yourself

How It Works

  1. Transform slot 0. R.multiply(10) turns 1 into 10.
  2. New array. The change goes into a copy, so result is [10, 2, 3].
  3. Input preserved. nums is still [1, 2, 3].
  4. Different reference. result === nums is false — handy for change detection in UI state.

Example 4 — Update One Object in a List

Mark the second to-do as done by returning a new object with R.assoc.

Ramda
const todos = [
  { title: 'Read', done: false },
  { title: 'Code', done: false }
];

const updated = R.adjust(1, R.assoc('done', true), todos);

console.log(updated[1]);           // { title: 'Code', done: true }
console.log(todos[1].done);        // false
console.log(updated[0] === todos[0]); // true
Try It Yourself

How It Works

  1. Build the transformer. R.assoc('done', true) returns a copy of an object with done: true.
  2. Apply at slot 1. Only the 'Code' item is replaced.
  3. Original safe. todos[1].done is still false because assoc never mutates.
  4. Shallow copy. Untouched items are shared: updated[0] === todos[0] is true.

Example 5 — Curried in a Pipeline

Leave out the list to get a reusable step, then capitalize a word inside R.pipe.

Ramda
const capitalizeFirst = R.adjust(0, R.toUpper);

const capitalize = R.pipe(R.split(''), capitalizeFirst, R.join(''));

console.log(capitalize('ramda')); // "Ramda"
console.log(capitalize('list'));  // "List"
Try It Yourself

How It Works

  1. Curry. R.adjust(0, R.toUpper) has no list yet, so it returns a function waiting for one.
  2. Split. R.split('') turns 'ramda' into ['r', 'a', 'm', 'd', 'a'].
  3. Adjust. capitalizeFirst uppercases slot 0 → ['R', 'a', 'm', 'd', 'a'].
  4. Join. R.join('') glues the letters back → 'Ramda'. R.pipe runs the steps left to right.

Browser & Runtime Support

R.adjust() is plain JavaScript inside Ramda (available since v0.14.0; current argument order since v0.26.0). It uses no browser API, so support depends only on loading Ramda.

✓ Ramda 0.26.0+ · Any JS runtime

Ramda.js R.adjust()

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. The arrow functions in some examples need an ES2015+ engine, which every modern browser has.

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.adjust() Universal

Bottom line: Safe in any project that includes Ramda 0.26.0 or later (for the idx, fn, list order). Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. These labs load [email protected] from jsDelivr.

Frequently Asked Questions

R.adjust(idx, fn, list) returns a new copy of the list where the item at index idx is replaced by fn(item). The original list is not changed. Official sample: R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']) returns ['a', 'B', 'c', 'd'].
Yes. Negative indexes count from the end, so -1 is the last item: R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']) returns ['a', 'b', 'c', 'D'].
When idx >= list.length or idx < -list.length, R.adjust returns the original list unchanged. It does not throw, does not call fn, and does not make a copy.
R.adjust takes a function and transforms the current value: adjust(1, R.toUpper, list). R.update takes a plain value and replaces the item: update(1, 'X', list). Use adjust when the new value depends on the old one.
No. It makes a shallow copy, so the other items are shared with the original list. If fn mutates an object, the original changes too. Return a new object instead, for example with R.assoc or R.evolve.
No. R.adjust has been a stable Ramda list function since v0.14.0. It is not deprecated, experimental, or non-standard. The argument order changed to (idx, fn, list) in v0.26.0.

Next: R.all()

Return true only when every item in a list passes your test.

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