A list helper that removes consecutive repeats, where you decide what “repeat” means. You pass a two-argument test; when it returns true, the later neighbour is dropped. The first item of every run stays, and the original list is never changed. Part of Ramda List since v0.14.0 (stable — not deprecated, experimental, or non-standard).
Why a custom test?R.dropRepeats only knows exact equality. With dropRepeatsWith, -4 and 4, "A" and "a", or two rows with the same status can count as the same thing.
Syntax
Call R.dropRepeatsWith. Start with this line.
Ramda
R.dropRepeatsWith(pred, list)
Call
What it does
R.dropRepeatsWith(pred, list)
Primary signature.
R.dropRepeatsWith(...)
Call the list helper.
Prefer import { dropRepeatsWith } from "ramda" when you want a named import.
Library declarations
Ramda
R.dropRepeatsWith(pred, list)
Parameters
Parameter
Description
pred
Required. (a, b) → Boolean — truthy means "same"
list
Required. The array to clean
Return Value
Return Value
Description
*
A new array with the first item of each run
Ramda Examples
Example 1 — Official Same-Absolute-Value Test
Treat 4 and -4 as the same, then drop neighbouring repeats.
Curried. Passing only the test returns collapseRuns, a function waiting for a list.
Case-insensitive test.R.toLower inside R.eqBy makes "red", "Red", and "RED" equal.
Neighbours only."Red" is dropped (it follows "red"), but "RED" follows "blue", so it stays.
Everywhere.R.uniqWith drops a word if it appeared anywhere earlier, leaving ["red", "blue"].
Compatibility
Browser & Runtime Support
R.dropRepeatsWith is a Ramda List helper since v0.14.0. It uses only basic array indexing, so it runs anywhere Ramda runs — browsers via CDN or bundler, and Node.js / Bun / Deno with npm install ramda.
✓ Stable · Ramda 0.14.0+
R.dropRepeatsWith()
Support depends on the Ramda version you load, not on a browser feature. Your own test function must also be valid in that runtime — e.g. arrow functions need an ES2015 engine.
100%Modern browsers & runtimes
Google ChromeModern versions · Desktop & Mobile
Full support
Mozilla FirefoxModern versions · Desktop & Mobile
Full support
Apple SafariModern versions · macOS & iOS
Full support
Microsoft EdgeChromium-based
Full support
OperaModern versions
Full support
Samsung InternetModern versions · Android
Full support
Android WebViewModern WebView
Full support
Internet ExplorerNot a target for current Ramda releases
Legacy
Node.jsMaintained LTS · npm install ramda
Supported
Bunimport from "ramda"
Supported
Denoimport from "npm:ramda"
Supported
R.dropRepeatsWithRamda 0.14.0+
Bottom line: Safe for production in any modern browser or JavaScript runtime once Ramda is loaded. The labs on this page use [email protected] from a CDN.
Frequently Asked Questions
R.dropRepeatsWith(pred, list) returns a new list without consecutive repeats, where your predicate decides what counts as a repeat. The first item of each run is kept. The docs sample is R.dropRepeatsWith(R.eqBy(Math.abs), [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]) //=> [1, 3, 4, -5, 3].
A truthy result means the two items are equal, so the later one is dropped. A falsy result keeps it. This is the opposite of R.filter, where true means keep.
It compares the last item already kept with the next item in the list: pred(lastKept, next). After a skip, the last kept item stays the same, so the next comparison is still against it — not against the item that was just skipped.
R.dropRepeats(list) is R.dropRepeatsWith(R.equals, list). R.dropRepeatsBy(fn, list) is R.dropRepeatsWith(R.eqBy(fn), list). Use dropRepeatsWith when your rule needs both items at once, such as a tolerance check or a field comparison.
dropRepeatsWith only removes neighbours, so a value can come back after a different one. R.uniqWith removes repeats anywhere in the list. For ['red', 'blue', 'red'] with R.equals, dropRepeatsWith keeps all three; uniqWith returns ['red', 'blue'].
No. R.dropRepeatsWith has been part of Ramda since v0.14.0 and is stable — not deprecated, experimental, or non-standard.