# subsets function

All the sublists of a list that keep its order, as a list.

## How to write it

### subsets(list)

**list**

The list. Takes a list.

## Examples

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

  `subsets([1, 2, 3])`

  In the solver, `subsets([1, 2, 3])` gives `[[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]`.

  [Open in the solver](https://hilberon.com/?q=subsets%28%5B1%2C%202%2C%203%5D%29)

## Related functions

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

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

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

  The first elements of a list.
- [select](https://hilberon.com/library/select)

  The elements of a list for which a test holds.
- [tally](https://hilberon.com/library/tally)

  How often each element occurs: a list of element and count pairs.
- [rotate_right](https://hilberon.com/library/rotate_right)

  A list with its elements moved to the right, the last ones going to the front.

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