# decrement function

Subtract 1 from a variable in place and return its old value.

## How to write it

### decrement(name)

**name**

The variable to update. Takes a variable.

## Examples

- $\displaystyle a := 1;\; \operatorname{decrement}(a);\; a \; 0$

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

  In the solver, `a := 1; decrement(a); a` gives `0`.

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

## Related functions

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

  Subtract 1 from a variable 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.
- [construct](https://hilberon.com/library/construct)

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

  Evaluate an expression even where it would be held.
- [add_to](https://hilberon.com/library/add_to)

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

  A function with no name; also written x => body.

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