Type Alias FunctionDefinitionFlags

FunctionDefinitionFlags: {
    associative: boolean;
    commutative: boolean;
    idempotent: boolean;
    inert: boolean;
    involution: boolean;
    numeric: boolean;
    pure: boolean;
    threadable: boolean;
}

A function definition can have some flags to indicate specific properties of the function.

Type declaration

  • associative: boolean

    If true, ["f", ["f", a], b] simplifies to ["f", a, b]

    Default: false

  • commutative: boolean

    If true, ["f", a, b] equals ["f", b, a]. The canonical version of the function will order the arguments.

    Default: false

  • idempotent: boolean

    If true, ["f", ["f", x]] simplifies to ["f", x].

    Default: false

  • inert: boolean

    An inert function evaluates directly to one of its argument, typically the first one. They may be used to provide formating hints, but do not affect simplification or evaluation.

    Default: false

  • involution: boolean

    If true, ["f", ["f", x]] simplifies to x.

    Default: false

  • numeric: boolean

    All the arguments of a numeric function are numeric, and its value is numeric.

  • pure: boolean

    If true, the value of this function is always the same for a given set of arguments and it has no side effects.

    An expression using this function is pure if the function and all its arguments are pure.

    For example Sin is pure, Random isn't.

    This information may be used to cache the value of expressions.

    Default: true

  • threadable: boolean

    If true, the function is applied element by element to lists, matrices (["List"] or ["Tuple"] expressions) and equations (relational operators).

    Default: false