# select function

The elements of a list for which a test holds.

## How to write it

### select(list, test)

**list**

The list. Takes a list.

**test**

A function that is true or false for an element. Takes a function.

## Examples

- $\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)`

  In the solver, `select([1, 2, 3, 4], x => x > 2)` gives `[3, 4]`.

  [Open in the solver](https://hilberon.com/?q=select%28%5B1%2C%202%2C%203%2C%204%5D%2C%20x%20%3D%3E%20x%20%3E%202%29)

## Related functions

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

  A list in increasing order.
- [rotate_right](https://hilberon.com/library/rotate_right)

  A list with its elements moved to the right, the last ones going to the front.
- [subsets](https://hilberon.com/library/subsets)

  All the sublists of a list that keep its order, as a list.
- [rotate_left](https://hilberon.com/library/rotate_left)

  A list with its elements moved to the left, the first ones going to the end.
- [table](https://hilberon.com/library/table)

  Build a list by evaluating an expression over one or more ranges.
- [riffle](https://hilberon.com/library/riffle)

  A list with a value put between its elements.

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