map-accum-right

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
969 B
The `mapAccumRight` function behaves like a combination of map and reduce; it
1 contributor
Install map-accum-right as a package?
Copied
npm i @bit/justin-capalbo.ramda.map-accum-right
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
mapAccumRight (
fn:Function,
acc:*,
list:Array
) : *

The mapAccumRight function behaves like a combination of map and reduce; it applies a function to each element of a list, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new list.

Similar to mapAccum, except moves through the input list from the right to the left.

The iterator function receives two arguments, acc and value, and should return a tuple [acc, value].

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']]
Arguments
fn: Function

The function to be called on every element of the input list.

acc: *

The accumulator value.

list: Array

The list to iterate over.

Returns
*

The final, accumulated value.

Help and resources