-
Notifications
You must be signed in to change notification settings - Fork 1
searchValueRight
Subhajit Sahu edited this page Jun 24, 2020
·
16 revisions
Finds last index of a value. 🏃 📼 📦 🌔 📒
Alternatives: searchValue, searchValueRight, searchValueAll.
Similar: [values], [isValue], searchValue.
Similar: search, scan, find.
iterable.searchValueRight(x, v, [fc], [fm]);
// x: an iterable
// v: search value
// fc: compare function (a, b)
// fm: map function (v, i, x)
// --> index of value, -1 if not found
const iterable = require('extra-iterable');
var x = [1, 2, 3, 2, 5];
iterable.searchValueRight(x, 2);
// 3 ^
var x = [1, 2, 3, -2, 5];
iterable.searchValueRight(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
// 3 ^
iterable.searchValueRight(x, 2, null, v => Math.abs(v));
// 3 ^