@extra-array/is-disjoint
Version:
Checks if arrays have no value in common.
57 lines (41 loc) • 1.62 kB
Markdown
Checks if arrays have no value in common.
[:package:](https://www.npmjs.com/package/@extra-array/is-disjoint)
[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
[:running:](https://npm.runkit.com/@extra-array/is-disjoint)
[:vhs:](https://asciinema.org/a/332075)
[:moon:](https://www.npmjs.com/package/@extra-array/is-disjoint.min)
[:scroll:](https://unpkg.com/@extra-array/is-disjoint/)
[:newspaper:](https://nodef.github.io/extra-array/)
[:blue_book:](https://github.com/nodef/extra-array/wiki/)
> Similar: [isUnique], [isDisjoint], [intersection].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
<br>
```javascript
array.isDisjoint(x, y, [fc], [fm]);
// x: an array
// y: another array
// fc: compare function (a, b)
// fm: map function (v, i, x)
```
> :stopwatch: Compare function => O(n²).
```javascript
const array = require("extra-array");
var x = [1, 2, 3, 4];
array.isDisjoint(x, [2, 5]);
// false
array.isDisjoint(x, [-2, -5]);
// true
array.isDisjoint(x, [-2, -5], (a, b) => Math.abs(a) - Math.abs(b));
// false
array.isDisjoint(x, [-2, -5], null, v => Math.abs(v));
// false
```
<br>
<br>
## References
- [Data.Set.disjoint: Haskell](http://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Set.html#v:disjoint)
- [Set.isdisjoint: Python](https://www.programiz.com/python-programming/methods/set/isdisjoint)
[intersection]: https://github.com/nodef/extra-array/wiki/intersection
[isUnique]: https://github.com/nodef/extra-array/wiki/isUnique
[isDisjoint]: https://github.com/nodef/extra-array/wiki/isDisjoint