Example 1 — Official Index 1 and -1
Uppercase the second letter, then the last one — the samples from the Ramda docs.
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'] How It Works
- Find the slot. Index
1is'b'(slots start at0). - Transform it.
R.toUpper('b')→'B'goes into a new copy. - Count from the end.
-1becomes(4 + -1) % 4 = 3→'d'→'D'. - Same idea as
at(). Negative positions work likeArray.at(-1).
