add an "ifCondition" parameter to rules, so you can programatically choose whether a rule applies or not #2901
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found that when calling
simplify
with equations in different orders (such as "x + x^2" vs "x^2 + x"), I'd get different results. I wanted to make a consistent way to sort terms, and found there wasn't a conditional way to apply simplification rules; you can only either make a rule that always applies or make a change based on the entire node tree (which means I'd need to write my own matching code).As such, I propose adding an optional function, I called "ifCondition" , that you can place on a rule. It gets passed the matches that are being currently looked at, and if the function returns false, then the swap is not made, and if it returns true, then it is made.