Using Ramda, and pointfree style, how can I copy the first item of an array to the end of it?

后端 未结 2 1471
一个人的身影
一个人的身影 2021-01-25 01:27

I want to take an array [1, 2, 3] and return [1, 2, 3, 1].

I\'m using Ramda, and I can get the desired result like this:

const          


        
2条回答
  •  别那么骄傲
    2021-01-25 02:00

    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]
    

提交回复
热议问题