1 | Checks if array has a subsequence. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:]
|
2 | > Similar: [subsequence], [subsequences], [isSubsequence], [searchSubsequence].<br>
|
3 | > Similar: [isValue], [isPrefix], [isInfix], [isSuffix], [isSubsequence], [isPermutation].<br>
|
4 | > This is part of package [extra-array].
|
5 |
|
6 | [extra-array]: https://www.npmjs.com/package/extra-array
|
7 |
|
8 | ```javascript
|
9 | array.isSubsequence(x, y, [fc], [fm]);
|
10 | // x: an array
|
11 | // y: subsequence?
|
12 | // fc: compare function (a, b)
|
13 | // fm: map function (v, i, x)
|
14 | ```
|
15 |
|
16 | ```javascript
|
17 | const array = require('extra-array');
|
18 |
|
19 | var x = [1, 2, 3, 4];
|
20 | array.isSubsequence(x, [2, 4]);
|
21 | // true
|
22 |
|
23 | array.isSubsequence(x, [-2, -4]);
|
24 | // false
|
25 |
|
26 | array.isSubsequence(x, [-2, -4], (a, b) => Math.abs(a) - Math.abs(b));
|
27 | // true
|
28 |
|
29 | array.isSubsequence(x, [-2, -4], null, v => Math.abs(v));
|
30 | // true
|
31 | ```
|
32 |
|
33 | ### references
|
34 |
|
35 | - [Data.List.isSubsequenceOf: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:isSubsequenceOf)
|
36 | - [List-Extra.isSubsequenceOf: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#isSubsequenceOf)
|
37 |
|
38 | [:running:]: https://npm.runkit.com/@extra-array/is-subsequence
|
39 | [:package:]: https://www.npmjs.com/package/@extra-array/is-subsequence
|
40 | [:moon:]: https://www.npmjs.com/package/@extra-array/is-subsequence.min
|
41 | [subsequence]: https://github.com/nodef/extra-array/wiki/subsequence
|
42 | [subsequences]: https://github.com/nodef/extra-array/wiki/subsequences
|
43 | [isSubsequence]: https://github.com/nodef/extra-array/wiki/isSubsequence
|
44 | [:ledger:]: https://unpkg.com/@extra-array/is-subsequence/
|
45 | [:vhs:]: https://asciinema.org/a/332082
|
46 | [searchSubsequence]: https://github.com/nodef/extra-array/wiki/searchSubsequence
|
47 | [isValue]: https://github.com/nodef/extra-array/wiki/isValue
|
48 | [isPrefix]: https://github.com/nodef/extra-array/wiki/isPrefix
|
49 | [isInfix]: https://github.com/nodef/extra-array/wiki/isInfix
|
50 | [isSuffix]: https://github.com/nodef/extra-array/wiki/isSuffix
|
51 | [isPermutation]: https://github.com/nodef/extra-array/wiki/isPermutation
|