Example 1 — Official: Combine Items by Position
The Ramda docs use a placeholder f. Here f joins each number with the letter at the same index.
const f = (x, y) => x + y;
console.log(R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']));
// ['1a', '2b', '3c'] How It Works
- Index 0. Ramda calls
f(1, 'a'), and1 + 'a'is'1a'. - Index 1.
f(2, 'b')gives'2b'. - Index 2.
f(3, 'c')gives'3c'. - Result. One call per position, so 3 results:
[f(1, 'a'), f(2, 'b'), f(3, 'c')].
