@extra-array/unfoldr
v2.2.1
Published
Builds array from a seed value (dual to foldr).
Downloads
91
Maintainers
Readme
Builds array from a seed value (dual to foldr).
This is part of package extra-array.
array.unfoldr(x, fn, v);
// fn: unreduce fn (v, i, x)
// v: initial value of accumulator
// --> built array
const array = require('extra-array');
array.unfoldr(v => v===0? undefined : [v, v-1], 10);
// [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]