calc method

  1. @override
num calc(
  1. MathVariableValues values, {
  2. MathCustomFunctionsImplemented customFunctions = const MathCustomFunctionsImplemented({}),
})
override

Evaluate the expression

Will calculate the value of the given expression using the given x value The x variable

When you mentioning an x in your expression, that part of the expression becomes inconstant and will change its result based on the given value.

You can check an expression or its parts (subnodes) for being constant with the isConst() method of the ExtensionConstant* extension family.

Implementation

@override
num calc(
  MathVariableValues values, {
  MathCustomFunctionsImplemented customFunctions =
      const MathCustomFunctionsImplemented({}),
}) {
  final d = definition;

  if (d is MathDefinitionFunctionFreeformImplemented) {
    return d.calc(
      arguments,
      values,
      customFunctions: customFunctions,
    );
  }

  return customFunctions[d].calc(
    arguments,
    values,
    customFunctions: customFunctions,
  );
}