函数 count #
计算矩阵、数组或字符串的元素数量。
Syntax #
math.count(x)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
string | Array | Matrix | 一个矩阵或字符串 |
Returns #
| Type | Description |
|---|---|
| number | 一个包含 x 中元素的整数。 |
Throws #
Type | Description —- | ———–
Examples #
math.count('hello world') // returns 11
const A = [[1, 2, 3], [4, 5, 6]]
math.count(A) // returns 6
math.count(math.range(1,6)) // returns 5