Skip to content

Commit

Permalink
Simplify 'every2DArray'
Browse files Browse the repository at this point in the history
  • Loading branch information
zoddicus committed Oct 23, 2023
1 parent bf48a54 commit 13b3ec7
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/webgpu/util/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2250,18 +2250,10 @@ export function map2DArray<T, S>(m: T[][], op: (input: T) => S): S[][] {
* @returns a boolean indicating if the test passed for every element
*/
export function every2DArray<T>(m: T[][], op: (input: T) => boolean): boolean {
const c = m.length;
const r = m[0].length;
assert(
m.every(c => c.length === r),
`Unexpectedly received jagged array to map`
);
for (let i = 0; i < c; i++) {
for (let j = 0; j < r; j++) {
if (!op(m[i][j])) {
return false;
}
}
}
return true;
return m.every(col => col.every(el => op(el)));
}

0 comments on commit 13b3ec7

Please sign in to comment.