R.addIndex(fn) wraps a list iterator so its callback also receives the current index and the whole list. That turns R.map into something closer to Array.prototype.map.
Stable:R.addIndex has been in Ramda since v0.15.0. It is not deprecated, experimental, or non-standard.
Syntax
Call R.addIndex. Start with this line.
Ramda
R.addIndex(fn)
Call
What it does
R.addIndex(fn)
Primary signature.
R.addIndex(...)
Call the function helper.
Prefer import { addIndex } from "ramda" when you want a named import.
Library declarations
Ramda
R.addIndex(fn)
Parameters
Parameter
Description
fn
Required. Iterator to wrap (e.g. R.map)
Callback
Required. Gets original args + index + list
List
Required. Last argument of the wrapped iterator
Return Value
Return Value
Description
*
New curried iterator (original unchanged)
Ramda Examples
Example 1 — Official mapIndexed
Wrap R.map once, then prefix every value with its index.
Receive the list. The wrapper passes list after idx.
Compare.idx === list.length - 1 is true only for the final item.
Suffix. Only 'gamma' becomes 'gamma (last)'.
Ignore when unused. If you only need the index, write (val, idx) and skip list.
Compatibility
Browser & Runtime Support
R.addIndex is a Ramda Function helper since v0.15.0. It is plain JavaScript — no special browser API. It runs anywhere Ramda loads (CDN, npm, bundler).
✓ Stable · Ramda 0.15.0+
R.addIndex()
Available in [email protected]+ full builds. Works in evergreen browsers and current Node LTS / Bun / Deno when Ramda is installed.
100%With Ramda 0.15+
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
R.addIndexRamda 0.15.0+
Bottom line: Safe for production once Ramda 0.15.0+ is loaded. Use a CDN build such as ramda.min.js in the browser, or npm install ramda for Node. No polyfill is needed beyond shipping Ramda itself.
Frequently Asked Questions
R.addIndex(fn) takes a list iterator such as R.map, R.filter, or R.reduce and returns a new iterator whose callback also receives the current index and the whole list. That makes Ramda's R.map closer to Array.prototype.map.
Ramda iterators pass only the current value by design, which keeps them simple and point-free. When you need the index, wrap the iterator with R.addIndex instead of switching to a native array method.
It works when the iteration callback is the first parameter and the list is the last parameter. That matches R.map, R.filter, R.forEach, and R.reduce. It will not magically fix a function with a different argument order.
Both add (value, index, list) to the callback. R.addIndex walks left to right (index 0 first). R.addIndexRight walks right to left, so indexes count from the end.
No. R.addIndex is a stable Ramda Function helper from v0.15.0. It is not deprecated, experimental, or non-standard.