mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
889 B
889 B
Function setMultiplicity
Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.
Syntax
math.setMultiplicity(element, set)
Parameters
| Parameter | Type | Description |
|---|---|---|
e |
number | BigNumber | Fraction | Complex | An element in the multiset |
a |
Array | Matrix | A multiset |
Returns
| Type | Description |
|---|---|
| number | The number of how many times the multiset contains the element |
Examples
math.setMultiplicity(1, [1, 2, 2, 4]) // returns 1
math.setMultiplicity(2, [1, 2, 2, 4]) // returns 2