# indicator function

A condition as a number: 1 when it is true and 0 when it is false.

## How to write it

### indicator(condition)

**condition**

A condition that is true or false, such as x > 0. Takes a condition, true or false.

## Examples

- $\displaystyle \operatorname{indicator}(1 < 2) = 1$

  `indicator(1 < 2)`

  In the solver, `indicator(1 < 2)` gives `1`.

  [Open in the solver](https://hilberon.com/?q=indicator%281%20%3C%202%29)

## Related functions

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

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

  Add 1 to a variable in place and return its old value.
- [pre_decrement](https://hilberon.com/library/pre_decrement)

  Subtract 1 from a variable in place and return the new value.
- [ifelse](https://hilberon.com/library/ifelse)

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

  Add 1 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/indicator
