1 |
|
2 |
|
3 | # Function setSize
|
4 |
|
5 | Count the number of elements of a (multi)set. When a second parameter is 'true', count only the unique values.
|
6 | A multi-dimension array will be converted to a single-dimension array before the operation.
|
7 |
|
8 |
|
9 | ## Syntax
|
10 |
|
11 | ```js
|
12 | math.setSize(set)
|
13 | math.setSize(set, unique)
|
14 | ```
|
15 |
|
16 | ### Parameters
|
17 |
|
18 | Parameter | Type | Description
|
19 | --------- | ---- | -----------
|
20 | `a` | Array | Matrix | A multiset
|
21 |
|
22 | ### Returns
|
23 |
|
24 | Type | Description
|
25 | ---- | -----------
|
26 | number | The number of elements of the (multi)set
|
27 |
|
28 |
|
29 | ## Examples
|
30 |
|
31 | ```js
|
32 | math.setSize([1, 2, 2, 4]) // returns 4
|
33 | math.setSize([1, 2, 2, 4], true) // returns 3
|
34 | ```
|
35 |
|
36 |
|
37 | ## See also
|
38 |
|
39 | [setUnion](setUnion.md),
|
40 | [setIntersect](setIntersect.md),
|
41 | [setDifference](setDifference.md)
|