mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
42 lines (26 loc) • 866 B
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
# Function setSize
Count the number of elements of a (multi)set. When a second parameter is 'true', count only the unique values.
A multi-dimension array will be converted to a single-dimension array before the operation.
## Syntax
```js
math.setSize(set)
math.setSize(set, unique)
```
### Parameters
Parameter | Type | Description
--------- | ---- | -----------
`a` | Array | Matrix | A multiset
### Returns
Type | Description
---- | -----------
number | The number of elements of the (multi)set
## Examples
```js
math.setSize([1, 2, 2, 4]) // returns 4
math.setSize([1, 2, 2, 4], true) // returns 3
```
## See also
[setUnion](setUnion.md),
[setIntersect](setIntersect.md),
[setDifference](setDifference.md)