unfold

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
1
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
N/A
Builds a list from a seed value.
1 contributor
Install unfold as a package?
Copied
npm i @bit/justin-capalbo.ramda.unfold
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
unfold (
fn:Function,
seed:*
) : Array

Builds a list from a seed value. Accepts an iterator function, which returns either false to stop iteration or an array of length 2 containing the value to add to the resulting list and the seed to be used in the next call to the iterator function.

The iterator function receives one argument: (seed).

Example
const f = n => n > 50 ? false : [-n, n + 10];
     R.unfold(f, 10); //=> [-10, -20, -30, -40, -50]
Arguments
fn: Function

The iterator function. receives one argument, seed, and returns either false to quit iteration or an array of length two to proceed. The element at index 0 of this array will be added to the resulting array, and the element at index 1 will be passed to the next call to fn.

seed: *

The seed value.

Returns
Array

The final list.

Help and resources