Skip to content

searchInfixRight

Subhajit Sahu edited this page Jun 20, 2020 · 12 revisions

Finds last index of an infix. 🏃 📼 📦 🌔 📒

Alternatives: searchInfix, searchInfixRight, searchInfixAll.
Similar: isInfix, searchInfix.
Similar: search, scan, find.

iterable.searchInfixRight(x, y, fc, [fm]);
// x:  an iterable
// y:  search infix
// fc: compare function (a, b)
// fm: map function (v, i, x)
const iterable = require('extra-iterable');

var x = [1, 2, 3, 4];
var y = [2, 3];
iterable.searchInfixRight(x, y);
// 1

var y = [-2, -3];
iterable.searchInfixRight(x, y);
// -1

iterable.searchInfixRight(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// 1

iterable.searchInfixRight(x, y, null, v => Math.abs(v));
// 1

references

Clone this wiki locally