1 |
|
2 |
|
3 | # Function count
|
4 |
|
5 | Count the number of elements of a matrix, array or string.
|
6 |
|
7 |
|
8 | ## Syntax
|
9 |
|
10 | ```js
|
11 | math.count(x)
|
12 | ```
|
13 |
|
14 | ### Parameters
|
15 |
|
16 | Parameter | Type | Description
|
17 | --------- | ---- | -----------
|
18 | `x` | string | Array | Matrix | A matrix or string
|
19 |
|
20 | ### Returns
|
21 |
|
22 | Type | Description
|
23 | ---- | -----------
|
24 | number | An integer with the elements in `x`.
|
25 |
|
26 |
|
27 | ## Examples
|
28 |
|
29 | ```js
|
30 | math.count('hello world') // returns 11
|
31 | const A = [[1, 2, 3], [4, 5, 6]]
|
32 | math.count(A) // returns 6
|
33 | math.count(math.range(1,6)) // returns 5
|
34 | ```
|
35 |
|
36 |
|
37 | ## See also
|
38 |
|
39 | [size](size.md)
|