I want to take an array [1, 2, 3] and return [1, 2, 3, 1].
[1, 2, 3]
[1, 2, 3, 1]
I\'m using Ramda, and I can get the desired result like this:
const
The S combinator is useful here:
S.S(S.C(R.append), R.head, [1, 2, 3]); // => [1, 2, 3, 1]
converge can be very helpful for things like this.
const rotate = R.converge(R.append, [R.head, R.identity]) rotate([1, 2, 3]); //=> [1, 2, 3, 1]