(size: number, call: (index: number) => T)
| 9 | * Create an array of arbitrary size by calling a function x times and saving its return value in the array |
| 10 | */ |
| 11 | export function arrayGenerate<T>(size: number, call: (index: number) => T): T[] { |
| 12 | const result: T[] = []; |
| 13 | for (let i = 0; i < size; i++) { |
| 14 | result.push(call(i)); |
| 15 | } |
| 16 | return result; |
| 17 | } |
| 18 | |
| 19 | /* |
| 20 | * Immutable insert function |