# tally function

How often each element occurs: a list of element and count pairs.

## How to write it

### tally(list)

**list**

The list. Takes a list.

## Examples

- $\displaystyle \operatorname{tally}(\left[ a, b, a \right]) = \begin{pmatrix} a & 2 \\ b & 1 \end{pmatrix}$

  `tally([a, b, a])`

  In the solver, `tally([a, b, a])` gives `[[a, 2], [b, 1]]`.

  [Open in the solver](https://hilberon.com/?q=tally%28%5Ba%2C%20b%2C%20a%5D%29)

## Related functions

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

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

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

  Sum of the elements of a list.
- [table](https://hilberon.com/library/table)

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

  The elements in any of some lists, each once, in order.
- [subsets](https://hilberon.com/library/subsets)

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

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