Skip to content

Instantly share code, notes, and snippets.

@fasiha
Created June 2, 2022 01:48
Show Gist options
  • Save fasiha/c93359e57b38351037ba1c0c595b2654 to your computer and use it in GitHub Desktop.
Save fasiha/c93359e57b38351037ba1c0c595b2654 to your computer and use it in GitHub Desktop.
function filteredLengthAtLeast<T>(
v: T[],
filter: (x: T) => boolean,
min: number,
) {
let nfound = 0;
for (let i = 0; i < v.length, nfound < min; i++) {
nfound += +filter(v[i]);
}
return nfound >= min;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment