-
Notifications
You must be signed in to change notification settings - Fork 1
searchAll
Subhajit Sahu edited this page Feb 3, 2021
·
29 revisions
Finds indices of values passing a test. 🏃 📼 📦 🌔 📒
Alternatives: search, searchRight, searchAll.
Similar: search, scan, find.
iterable.searchAll(x, ft);
// x: an iterable
// ft: test function (v, i, x)
// --> indices of value
const iterable = require("extra-iterable");
var x = [1, 2, 3, 4, 5];
[...iterable.searchAll(x, v => v % 2 == 0)];
// [ 1, 3 ] ^ ^
[...iterable.searchAll(x, v => v % 2 == 1)];
// [ 0, 2, 4 ] ^ ^