# fold function

Combine the elements of a list from the left with a function, starting from a value.

## How to write it

### fold(f, start, list)

**f**

A function of two arguments. Takes a function.

**start**

The first value. Takes an expression.

**list**

The elements to combine. Takes a list.

## Examples

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

  `fold(plus, 0, [1, 2, 3])`

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

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

## Related functions

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

  The steps of fold: every partial result, starting from the first value.
- [flatten](https://hilberon.com/library/flatten)

  Nested lists flattened into one list.
- [head](https://hilberon.com/library/head)

  The head of an expression: the name of the function it is a call of.
- [first](https://hilberon.com/library/first)

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

  The elements that are in every one of some lists.
- [drop](https://hilberon.com/library/drop)

  A list without its first elements.

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