Ramda Relation Methods
About This Index
This page is the Ramda Relation index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn the Ramda overview on /ramdajs. Use this page when you need a relation API such as R.equals(), R.union(), or R.sortBy().
Start with R.equals(), then R.gt() / R.lt(), R.union(), and R.sortBy()—add set ops with custom matchers as needed.
How to Call a Relation Method
Import R (or a named helper)—compare, order, and combine with data last:
const R = require("ramda");
R.equals({ a: 1 }, { a: 1 }); // true
R.identical(NaN, NaN); // true
R.gt(5, 3); // true
R.min(5, 3); // 3
R.clamp(1, 10, 15); // 10
R.union([1, 2], [2, 3]); // [1, 2, 3]
R.intersection([1, 2], [2, 3]); // [2]
R.difference([1, 2, 3], [2]); // [1, 3]
R.sortBy(R.prop("age"), [
{ name: "Bob", age: 30 },
{ name: "Ada", age: 25 }
]); // Ada then Bob
R.propEq("id", 1, { id: 1 }); // true Ramda Relation Methods Table
All Relation method guides in this Ramda tutorial series (25 tutorials).
Getting Started
4 methodsEquality, identity, custom compare, and clamp — the foundation of a Ramda relation tutorial.
| Method | Description | Tutorial |
|---|---|---|
R.equals() | Deep value equality for objects, arrays, and primitives. The default match test for set helpers. | Try it |
R.identical() | Strict SameValue equality (===). Use when reference or primitive identity matters, not deep structure. | Try it |
R.eqBy() | Compare two values after running the same function on each. Ideal for sorting or matching by a key. | Try it |
R.clamp() | Restrict a value to an inclusive min–max range. Returns min, max, or the value unchanged. | Try it |
Compare & Pick
8 methodsOrdering tests and min/max helpers for numbers, strings, dates, and projected keys.
| Method | Description | Tutorial |
|---|---|---|
R.gt() | Return true when the first ordered value is greater than the second. | Try it |
R.gte() | Return true when the first ordered value is greater than or equal to the second. | Try it |
R.lt() | Return true when the first ordered value is less than the second. | Try it |
R.lte() | Return true when the first ordered value is less than or equal to the second. | Try it |
R.min() | Return the smaller of two ordered values. | Try it |
R.max() | Return the larger of two ordered values. | Try it |
R.minBy() | Pick the item whose projected value is smallest. Uses a function to compare by key. | Try it |
R.maxBy() | Pick the item whose projected value is largest. Uses a function to compare by key. | Try it |
Property Equality
2 methodsBuild predicates that match one property or nested path on an object.
| Method | Description | Tutorial |
|---|---|---|
R.propEq() | Build a predicate that checks whether one property equals a value. | Try it |
R.pathEq() | Build a predicate that checks whether a nested path equals a value. | Try it |
Set Operations
7 methodsDifference, intersection, union, and symmetric difference with value or custom matching.
| Method | Description | Tutorial |
|---|---|---|
R.difference() | Return items in the first list that are not in the second, using R.equals for matching. | Try it |
R.differenceWith() | Like R.difference but with a custom predicate to decide when two items match. | Try it |
R.intersection() | Return unique items that appear in both lists, using R.equals for matching. | Try it |
R.union() | Return unique items from either list, deduped with R.equals. First-list order wins. | Try it |
R.unionWith() | Like R.union but with a custom predicate to decide when two items match. | Try it |
R.symmetricDifference() | Return items in either list but not in both, using R.equals for matching. | Try it |
R.symmetricDifferenceWith() | Like R.symmetricDifference but with a custom match predicate. | Try it |
Sort
2 methodsOrder lists by a computed key or by a stack of comparators.
| Method | Description | Tutorial |
|---|---|---|
R.sortBy() | Sort a list by a computed key. Stable ascending order by the accessor result. | Try it |
R.sortWith() | Sort a list using a list of comparator functions tried in order. | Try it |
Join & Count
2 methodsPair lists on a shared key or tally items grouped by a bucket function.
| Method | Description | Tutorial |
|---|---|---|
R.innerJoin() | Join two lists on a shared key, producing pairs of matching items. | Try it |
R.countBy() | Group list items by a key function and count how many fall in each bucket. | Try it |
Frequently Asked Questions
Start with R.equals()
Open the equals guide—syntax, examples, and FAQs.
16 people found this page helpful
