# Table of values (table)

Build a list by evaluating an expression over one or more ranges.

## How to write it

### table(expr, k = a..b)

A list with one element for each value of the index.

**expr**

Any expression: a number, a formula, a list or a matrix. Takes an expression.

**k = a..b**

The index and its bounds. Takes a variable with its range.

### table(expr, i = a..b, j = a..b)

A list of lists: a matrix when the ranges are numbers.

**expr**

Any expression: a number, a formula, a list or a matrix. Takes an expression.

**i = a..b**

The first index and its range. Takes a variable with its range.

**j = a..b**

The second index and its range. Takes a variable with its range.

## Examples

- $\displaystyle \operatorname{table}(k^{2}, k = 1 \ldots 5) = \left[ 1, 4, 9, 16, 25 \right]$

  `table(k^2, k = 1..5)`

  In the solver, `table(k^2, k = 1..5)` gives `[1, 4, 9, 16, 25]`.

  [Open in the solver](https://hilberon.com/?q=table%28k%5E2%2C%20k%20%3D%201..5%29)
- $\displaystyle \operatorname{table}(i j, i = 1 \ldots 3, j = 1 \ldots 3) = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9 \end{pmatrix}$

  `table(i*j, i = 1..3, j = 1..3)`

  In the solver, `table(i*j, i = 1..3, j = 1..3)` gives `[[1, 2, 3], [2, 4, 6], [3, 6, 9]]`.

  [Open in the solver](https://hilberon.com/?q=table%28i*j%2C%20i%20%3D%201..3%2C%20j%20%3D%201..3%29)

## Related functions

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

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

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

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

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

  Apply a function to corresponding elements of lists.
- [select](https://hilberon.com/library/select)

  The elements of a list for which a test holds.

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