unfold
Builds an array, using an iterator function and an initial seed value.
- Use a
whileloop andArray.prototype.push()to call the function repeatedly until it returnsfalse. - The iterator function accepts one argument (
seed) and must always return an array with two elements ([value,nextSeed]) orfalseto terminate.