Skip to content

hasInfix

Subhajit Sahu edited this page May 3, 2023 · 14 revisions

Examine if array contains an infix.

Similar: randomInfix, infixes, hasInfix, searchInfix.
Similar: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPermutation, hasPath.


function hasInfix(x, y, fc, fm)
// x:  an array
// y:  search infix
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xarray = require('extra-array');

var x = [1, 2, 3, 4];
xarray.hasInfix(x, [2, 3]);
// → true

xarray.hasInfix(x, [-2, -3]);
// → false

xarray.hasInfix(x, [-2, -3], (a, b) => Math.abs(a) - Math.abs(b));
// → true

xarray.hasInfix(x, [-2, -3], null, v => Math.abs(v));
// → true


References

Clone this wiki locally