UNPKG

@extra-array/has-subsequence

Version:

Checks if array has a subsequence.

64 lines (48 loc) 2.28 kB
Checks if array has a subsequence. [:package:](https://www.npmjs.com/package/@extra-array/has-subsequence) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/has-subsequence) [:vhs:](https://asciinema.org/a/343742) [:moon:](https://www.npmjs.com/package/@extra-array/has-subsequence.min) [:scroll:](https://unpkg.com/@extra-array/has-subsequence/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Similar: [subsequence], [subsequences], [hasSubsequence], [searchSubsequence].<br> > Similar: [hasValue], [hasPrefix], [hasInfix], [hasSuffix], [hasSubsequence], [hasPermutation], [hasPath]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.hasSubsequence(x, y, [fc], [fm]); // x: an array // y: subsequence? // fc: compare function (a, b) // fm: map function (v, i, x) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4]; array.hasSubsequence(x, [2, 4]); // true array.hasSubsequence(x, [-2, -4]); // false array.hasSubsequence(x, [-2, -4], (a, b) => Math.abs(a) - Math.abs(b)); // true array.hasSubsequence(x, [-2, -4], null, v => Math.abs(v)); // true ``` <br> <br> ## References - [Data.List.isSubsequenceOf: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:isSubsequenceOf) - [List-Extra.isSubsequenceOf: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#isSubsequenceOf) [subsequence]: https://github.com/nodef/extra-array/wiki/subsequence [subsequences]: https://github.com/nodef/extra-array/wiki/subsequences [hasSubsequence]: https://github.com/nodef/extra-array/wiki/hasSubsequence [searchSubsequence]: https://github.com/nodef/extra-array/wiki/searchSubsequence [hasValue]: https://github.com/nodef/extra-array/wiki/hasValue [hasPrefix]: https://github.com/nodef/extra-array/wiki/hasPrefix [hasInfix]: https://github.com/nodef/extra-array/wiki/hasInfix [hasSuffix]: https://github.com/nodef/extra-array/wiki/hasSuffix [hasPermutation]: https://github.com/nodef/extra-array/wiki/hasPermutation [hasPath]: https://github.com/nodef/extra-array/wiki/hasPath