Example 1 — Every Combination of Options
Each inner array is a set of choices; the result lists every way to pick one from each.
const options = [['S', 'M'], ['red', 'blue']];
console.log(R.sequence(R.of(Array), options));
// [['S', 'red'], ['S', 'blue'], ['M', 'red'], ['M', 'blue']] How It Works
- Wrapper.
R.of(Array)tells Ramda the wrapper is an array. - Choices. There are 2 sizes and 2 colors.
- Pick one of each. Every size is paired with every color.
- Result. 2 × 2 = 4 outfits. For exactly two lists,
R.xprodgives the same pairs.
