# apply function

Replace the head of an expression, or the brackets of a list, with a function.

## How to write it

### apply(f, expr)

**f**

The function to put in place of the head. Takes a function.

**expr**

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

## Examples

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

  `apply(plus, [1, 2, 3])`

  In the solver, `apply(plus, [1, 2, 3])` gives `6`.

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

## Related functions

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

  The elements of a list that are in none of the others.
- [append](https://hilberon.com/library/append)

  A list with an element added at the end.
- [constant_array](https://hilberon.com/library/constant_array)

  A list of copies of a value.
- [accumulate](https://hilberon.com/library/accumulate)

  Running totals of a list.
- [count](https://hilberon.com/library/count)

  How many elements of a list equal a value.
- [union](https://hilberon.com/library/union)

  The elements in any of some lists, each once, in order.

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