I'm working on writing a small CAS framework for a project, and it stores mathematical expressions as trees, with each node being an operator, and it's branches being the parameters. It isn't a binary tree, as there are some nodes (such as negation or trig functions) that only have one parameter, and others (such as multiplication or addition) that can have almost any number of parameters.

My issue is that I am trying to include comparisons (==, <, >, <=, >=, !=) that are chainable. This is trivial with my system as long as every operator in the chain is the same (0 < x < 5), but for some applications they may not be (0 < x <= 5). I'm having trouble handling these cases with the framework I've written so far, and I'm wondering if there are any resources illustrating how this problem can/should be approached.

The reason these operators are necessary is solely to allow for piecewise expressions. It may be relevant that to state that I have also implemented boolean operators (and, or, xor, not). I think this may be important because 0 < x <= 5 is the same as stating 0 < x and x <= 5, but I would prefer to not require that if possible. Thanks for any input you may have.

0

There are 0 best solutions below