bertiqwerty / exmex

Math parser and evaluator in Rust, capable of partial differentiation, allows the use of custom operators.
Apache License 2.0
39 stars 6 forks source link

Output of functions without a variable #29

Closed Titaniumtown closed 2 years ago

Titaniumtown commented 2 years ago

Currently functions that don't contain a variable don't output a value, so for instance the function π doesn't just simply output 3.14.... no matter the output.

bertiqwerty commented 2 years ago

With your desired behavior, you could accidentally pass more values than you have variables without noticing. The current logic is that a parsed function depends on as many variables as found in the string. An exception is that a partial derivative always keeps as many variables as its antiderivative. Still, we might have this as an alternative interface. I will think about adding another evaluate function to the expression that is not so strict regarding the number of variables. Then it would not complain if you pass more values than variables in the expression and it could just ignore the unnecessary ones.