UNPKG

@thi.ng/tensors

Version:

0D/1D/2D/3D/4D tensors with extensible polymorphic operations and customizable storage

15 lines (14 loc) 255 B
const findIndex = (a, pred, start = 0, end = a.length) => { const { offset: oa, stride: [ta], data: adata } = a; for (let i = start; i < end; i++) { if (pred(adata[oa + i * ta])) return i; } return -1; }; export { findIndex };