Home > @josh-brown/vector > VectorBuilder > fromIndexFunction
Constructs a vector with entries given by _entry = f(i)_ where _f_ is valueFromIndex and i is the index of the element
Signature:
fromIndexFunction(dimension: number, valueFromIndex: VectorIndexFunction<S>): V;|
Parameter |
Type |
Description |
|---|---|---|
|
dimension |
number |
The dimension of the vector to generate |
|
valueFromIndex |
A function returning the entry for a given index |
Returns:
V
The new vector
vectorBuilder.fromIndexFunction(4, i => i + 3); // [ 3 4 5 6 ]