Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

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

  • indicator⁡(1<2)=1\displaystyle \operatorname{indicator}(1 < 2) = 1
    indicator(1 < 2)

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

    Open in the solver
  • piecewise

    Cases written value if condition, with an optional otherwise case.

  • increment

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

  • pre_decrement

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

  • ifelse

    A value chosen by a test.

  • pre_increment

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

  • function

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