|
def parser(self, math_json): |
In the polars parser you are using recursion. In here, you are using stack operations. This can make things unnecessarily difficult for future maintainers.
Also, if I am not wrong... The algorithm here only works for functions/operators with known arity (one or two in the cases you have implemented). We may eventually have cases with an unknown number of inputs. Infact, I would like you to implement two such functions: max and min.
You can find two valid JSON structures for these functions in the MathJSON documentation: https://cortexjs.io/compute-engine/reference/arithmetic/
Choose whichever one is easier to handle in your parsers and document the choice.