# add_to function

Add a value to a variable in place and return the new value.

## How to write it

### add_to(name, x)

There is no += in the language.

**name**

The variable to update. Takes a variable.

**x**

The amount to add. Takes an expression.

## Examples

- $\displaystyle a := 1;\; \operatorname{add\_to}(a, 2);\; a \; 3$

  `a := 1; add_to(a, 2); a`

  In the solver, `a := 1; add_to(a, 2); a` gives `3`.

  [Open in the solver](https://hilberon.com/?q=a%20%3A%3D%201%3B%20add_to%28a%2C%202%29%3B%20a)

## Related functions

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

  Apply a head that is itself computed to arguments, as in f'(0) or (x => body)(a).
- [with_effort](https://hilberon.com/library/with_effort)

  Evaluate a body at quick, standard, deep or exhaustive effort.
- [decrement](https://hilberon.com/library/decrement)

  Subtract 1 from a variable in place and return its old value.
- [times_by](https://hilberon.com/library/times_by)

  Multiply a variable by a value in place and return the new value.
- [divide_by](https://hilberon.com/library/divide_by)

  Divide a variable by a value in place and return the new value.
- [subtract_from](https://hilberon.com/library/subtract_from)

  Subtract a value from a variable in place and return the new value.

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