# subtract_from function

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

## How to write it

### subtract_from(name, x)

**name**

The variable to update. Takes a variable.

**x**

The amount to subtract. Takes an expression.

## Examples

- $\displaystyle a := 1;\; \operatorname{subtract\_from}(a, 2);\; a \; -1$

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

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

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

## Related functions

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

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

  Apply substitution rules again and again until nothing changes.
- [with_effort](https://hilberon.com/library/with_effort)

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

  The n-th argument of a function with no name: inside function(body), slot(1) is the first.
- [add_to](https://hilberon.com/library/add_to)

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

  Define a function; also written f(x) := body.

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