Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide a way to generate the inverse of a rule #8

Open
kevinbarabash opened this issue Apr 30, 2017 · 2 comments
Open

provide a way to generate the inverse of a rule #8

kevinbarabash opened this issue Apr 30, 2017 · 2 comments

Comments

@kevinbarabash
Copy link
Member

kevinbarabash commented Apr 30, 2017

const rule = defineRuleString('1 * #a', '#a')
const inverse = rule.inverse()  // equivalent to defineRuleString('#a', '1 * #a')
@aliang8
Copy link
Contributor

aliang8 commented Apr 30, 2017

Not every rule has an inverse (e.g 0 / 1 or 2 - -3). So we can limit the inverses to only rules on addition and multiplication. One solution would just be to reverse the arguments (assuming that there are only two, e.g #a + 0 -> 0 + #a). Or, since we don't have too many rules right now we can hard code it. But that wouldn't be too ideal considering we would probably want to find inverse of other operations. What do you think?

@kevinbarabash
Copy link
Member Author

It may be simpler to just write the reverse rules we want by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants