Variables and custom functions - Waigo01/math_utils_lib GitHub Wiki

The evaluator also allows for user defined variables and functions to be used during evaluation. Variables and functions can be defined using any name, as long as the name fulfills some rules (For more information on those rules, please take a look at docs.rs (Variable)). Note that the functions defined as operations take priority over user defined functions (although naming your function "sin" is valid, the operation "sin" will take priority).

Functions and Variables are bundled into a context. A corresponding code example would be:

let mut context = Context::default();
context.add_var(&Variable::new("x", vec![Value::Scalar(3.)]));

Apart from pi and e, which are given by Context::default, the context now also contains the variable x with the value 3.

⚠️ **GitHub.com Fallback** ⚠️