map-accum

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
968 B
The `mapAccum` function behaves like a combination of map and reduce; it
1 contributor
Install map-accum as a package?
Copied
npm i @bit/justin-capalbo.ramda.map-accum
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
mapAccum (
fn:Function,
acc:*,
list:Array
) : *

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

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) => [a + b, a + b];

     R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']]
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