-
Notifications
You must be signed in to change notification settings - Fork 1
hasSubsequence
Subhajit Sahu edited this page Feb 3, 2021
·
11 revisions
Checks if iterable has a subsequence. 🏃 📼 📦 🌔 📒
Alternatives: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPath.
Similar: hasSubsequence, searchSubsequence.
iterable.hasSubsequence(x, y, [fc], [fm]);
// x: an iterable
// y: subsequence?
// fc: compare function (a, b)
// fm: map function (v, i, x)
const iterable = require("extra-iterable");
var x = [1, 2, 3, 4];
iterable.hasSubsequence(x, [2, 4]);
// true
iterable.hasSubsequence(x, [-2, -4]);
// false
iterable.hasSubsequence(x, [-2, -4], (a, b) => Math.abs(a) - Math.abs(b));
// true
iterable.hasSubsequence(x, [-2, -4], null, v => Math.abs(v));
// true