Example 1 — Official mergeThree
Join three values into an array, then call the flipped version with the same arguments.
const mergeThree = (a, b, c) => [].concat(a, b, c);
mergeThree(1, 2, 3);
// → [1, 2, 3]
R.flip(mergeThree)(1, 2, 3);
// → [2, 1, 3] How It Works
- Normal call.
mergeThree(1, 2, 3)joins the values in order →[1, 2, 3]. - Wrap.
R.flip(mergeThree)returns a new function; nothing runs yet. - Swap. Calling it with
(1, 2, 3)makes Ramda runmergeThree(2, 1, 3). - Result.
[2, 1, 3]— only the first two values traded places.
