Skip to content

Commit

Permalink
Array.fromに変更、引数名を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
sigprogramming committed Nov 22, 2024
1 parent 31d54b2 commit c31aa15
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/sing/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ export function isSorted<T>(array: T[], compareFn: (a: T, b: T) => number) {

export function createArray<T>(
length: number,
generateElementsFn: (index: number) => T,
generateElementFn: (index: number) => T,
) {
const array: T[] = [];
for (let i = 0; i < length; i++) {
array.push(generateElementsFn(i));
}
return array;
return Array.from({ length }, (_, i) => generateElementFn(i));
}

export function linearInterpolation(
Expand Down

0 comments on commit c31aa15

Please sign in to comment.