# apply 函数

把表达式的头部或列表的括号替换为函数。

## 怎么写

### apply(f, expr)

**f**

用来替换头部的函数。接受一个函数。

**expr**

任意表达式：一个数、一个公式、一个列表或一个矩阵。接受一个表达式。

## 示例

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

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

  在求解器中，`apply(plus, [1, 2, 3])` 的结果是 `6`。

  [在求解器中打开](https://zh.hilberon.com/?q=apply%28plus%2C%20%5B1%2C%202%2C%203%5D%29)

## 相关函数

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

  某个列表中不在其他任何列表里的元素。
- [append](https://zh.hilberon.com/library/append)

  在末尾添加一个元素后的列表。
- [constant_array](https://zh.hilberon.com/library/constant_array)

  由某个值的若干副本组成的列表。
- [accumulate](https://zh.hilberon.com/library/accumulate)

  列表的累计总和。
- [count](https://zh.hilberon.com/library/count)

  列表中有多少个元素等于某个值。
- [union](https://zh.hilberon.com/library/union)

  出现在任意一个列表中的元素，每个只出现一次，按顺序。

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