Example 1 — Official: Every Pair of Two Lists
The sample from the Ramda docs: pair each number with each letter.
console.log(R.xprod([1, 2], ['a', 'b']));
// [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] How It Works
- Take 1. Pair it with every letter:
[1, 'a'],[1, 'b']. - Take 2. Pair it with every letter:
[2, 'a'],[2, 'b']. - Collect. All pairs go into one flat list of two-item arrays.
- Size. 2 numbers × 2 letters = 4 pairs.
