-
Notifications
You must be signed in to change notification settings - Fork 1
searchSubsequence
Subhajit Sahu edited this page Jun 15, 2020
·
14 revisions
Searches a subsequence. 🏃 📼 📦 🌔 📒
Similar: isPrefix, isInfix, isSuffix, isSubsequence. Similar: [search], [scan], [find].
iterable.searchSubsequence(x, y, [fc], [fm]);
// x: an iterable
// y: search subsequence
// fc: compare function (a, b)
// fm: map function (v, i, x)
// --> start index of subsequence, -1 if not found
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4];
iterable.isSubsequence(x, [2, 4]);
// true
iterable.isSubsequence(x, [-2, -4]);
// false
iterable.isSubsequence(x, [-2, -4], (a, b) => Math.abs(a) - Math.abs(b));
// true
iterable.isSubsequence(x, [-2, -4], null, v => Math.abs(v));
// true