# count 函数

列表中有多少个元素等于某个值。

## 怎么写

### count(list, x)

**list**

列表。接受一个列表。

**x**

要计数的值。接受一个表达式。

## 示例

- $\displaystyle \operatorname{count}(\left[ 1, 2, 1 \right], 1) = 2$

  `count([1, 2, 1], 1)`

  在求解器中，`count([1, 2, 1], 1)` 的结果是 `2`。

  [在求解器中打开](https://zh.hilberon.com/?q=count%28%5B1%2C%202%2C%201%5D%2C%201%29)

## 相关函数

- [dimensions](https://zh.hilberon.com/library/dimensions)

  列表或矩阵的大小，逐层给出。
- [constant_array](https://zh.hilberon.com/library/constant_array)

  由某个值的若干副本组成的列表。
- [drop](https://zh.hilberon.com/library/drop)

  去掉开头若干元素后的列表。
- [complement](https://zh.hilberon.com/library/complement)

  某个列表中不在其他任何列表里的元素。
- [first](https://zh.hilberon.com/library/first)

  列表的第一个元素。
- [apply](https://zh.hilberon.com/library/apply)

  把表达式的头部或列表的括号替换为函数。

---
Source: https://zh.hilberon.com/library/count
