# select 函数

列表中满足某个测试的元素。

## 怎么写

### select(list, test)

**list**

列表。接受一个列表。

**test**

对元素返回真或假的函数。接受一个函数。

## 示例

- $\displaystyle \operatorname{select}(\left[ 1, 2, 3, 4 \right], x \mapsto x > 2) = \left[ 3, 4 \right]$

  `select([1, 2, 3, 4], x => x > 2)`

  在求解器中，`select([1, 2, 3, 4], x => x > 2)` 的结果是 `[3, 4]`。

  [在求解器中打开](https://zh.hilberon.com/?q=select%28%5B1%2C%202%2C%203%2C%204%5D%2C%20x%20%3D%3E%20x%20%3E%202%29)

## 相关函数

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

  按递增顺序排列的列表。
- [rotate_right](https://zh.hilberon.com/library/rotate_right)

  列表的元素向右移动，末尾的元素移到开头。
- [subsets](https://zh.hilberon.com/library/subsets)

  列表所有保持顺序的子列表，以列表形式给出。
- [rotate_left](https://zh.hilberon.com/library/rotate_left)

  列表的元素向左移动，开头的元素移到末尾。
- [table](https://zh.hilberon.com/library/table)

  在一个或多个范围上求值表达式，构建列表。
- [riffle](https://zh.hilberon.com/library/riffle)

  在元素之间插入某个值后的列表。

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