How to use the mapAccumRight function from ramda

Find comprehensive JavaScript ramda.mapAccumRight code examples handpicked from public code repositorys.

2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
 * @example
 *
 *      var digits = ['1', '2', '3', '4'];
 *      var append = (a, b) => [a + b, a + b];
 *
 *      R.mapAccumRight(append, 0, digits); //=> ['04321', ['04321', '0432', '043', '04']]
 */
var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) {
    var idx = list.length - 1;
    var result = [];
fork icon0
star icon0
watch icon0

+ 17 other calls in file

784
785
786
787
788
789
790
791
792
793
794
795
    const idx = R.pipe(
        R.findIndex((cogs) => (cogs.date_from >= cogsToInsert.date_from)),
        negativeToValueCurried(cogsList.length)
    )(cogsList)
    const mergedList = R.insert(idx, cogsToInsert, cogsList)
    return R.mapAccumRight(setDateAsPrevious, -1, mergedList)[0]


}


function setDateAsPrevious(obj, accum) {
fork icon0
star icon0
watch icon0

+ 2 other calls in file

9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
* @example
*
*      const digits = ['1', '2', '3', '4'];
*      const appender = (a, b) => [b + a, b + a];
*
*      R.mapAccumRight(appender, 5, digits); //=> ['12345', ['12345', '2345', '345', '45']]
* @symb R.mapAccumRight(f, a, [b, c, d]) = [
*   f(f(f(a, d)[0], c)[0], b)[0],
*   [
*     f(a, d)[1],
fork icon0
star icon0
watch icon2

+ 7 other calls in file

121
122
123
124
125
126
127
128
129
130
  done()
})

it('Should fix date_to', function(done) {
  const mergedList = t.insertCOGSRecord(COGSList, COGSToInsert)
  const dateCorrectedList = R.mapAccumRight(t.setDateAsPrevious, -1, mergedList)[0]
  console.log('Corrected list ', dateCorrectedList)
  dateCorrectedList.should.have.lengthOf(2)
  dateCorrectedList[0].date_to.should.have.equalDate(moment().subtract(1, 'days').startOf('day').toDate())
  dateCorrectedList[1].date_from.should.have.equalDate(moment().startOf('day').toDate())
fork icon0
star icon0
watch icon0

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)