mathjs/docs/reference/functions/setDifference.md
2022-03-01 13:04:09 +01:00

52 lines
1.5 KiB
Markdown

---
layout: default
---
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
<h1 id="function-setdifference">Function setDifference <a href="#function-setdifference" title="Permalink">#</a></h1>
Create the difference of two (multi)sets: every element of set1, that is not the element of set2.
Multi-dimension arrays will be converted to single-dimension arrays before the operation.
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.setDifference(set1, set2)
```
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`a1` | Array &#124; Matrix | A (multi)set
`a2` | Array &#124; Matrix | A (multi)set
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
Array &#124; Matrix | The difference of two (multi)sets
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
Type | Description
---- | -----------
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
```js
math.setDifference([1, 2, 3, 4], [3, 4, 5, 6]) // returns [1, 2]
math.setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]]) // returns [1, 2]
```
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
[setUnion](setUnion.html),
[setIntersect](setIntersect.html),
[setSymDifference](setSymDifference.html)