Closed terrorfisch closed 2 years ago
Do you mean all user defined operators for that expression? How could a call look like?
let op_minus: Operator = todo!();
let diff1 = expr1.apply_binary_operator("-", expr2)?;
let diff2 = expr1.apply_binary(op_minus, expr2);
let diff3 = op_minus.apply_binary(expr1, expr2);
let neg1 = expr1.apply_unary_operator("-")?;
let neg2 = expr1.apply_unary(op_minus);
let neg3 = op_minus.apply_unary(expr1);
diff1
and neg1
would enforce that the operator is known to the OperatorFactory of the expression and is therefore the cleanest and most convenient. The other two variants are more flexible. I would be fine with all three variants.
I implemented something similar to compute partial derivatives. I will look into how to make this part of the public API. https://github.com/bertiqwerty/exmex/blob/07ce3de3dc20724f1498b4653ce0e6336d75b100/src/partial/mod.rs#L478
This is a feature I require and currently implement by formatting the expression(s) into a String with the required operator and reparsing it.