# increment function

Add 1 to a variable in place and return its old value.

## How to write it

### increment(name)

**name**

The variable to update. Takes a variable.

## Examples

- $\displaystyle a := 1;\; \operatorname{increment}(a);\; a \; 2$

  `a := 1; increment(a); a`

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

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

## Related functions

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

  Add 1 to a variable in place and return the new value.
- [indicator](https://hilberon.com/library/indicator)

  A condition as a number: 1 when it is true and 0 when it is false.
- [ifelse](https://hilberon.com/library/ifelse)

  A value chosen by a test.
- [piecewise](https://hilberon.com/library/piecewise)

  Cases written value if condition, with an optional otherwise case.
- [function](https://hilberon.com/library/function)

  A function with no name; also written x => body.
- [pre_decrement](https://hilberon.com/library/pre_decrement)

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

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