semantic-math / math-rules

Manipulate math-ast ASTs based on algebraic rules
MIT License
4 stars 1 forks source link

Add a special #eval node which evaluates the child expression #1

Closed kevinbarabash closed 7 years ago

kevinbarabash commented 7 years ago

Given the following rule:

const rule = defineRule('#a #x + #b #x', '#eval(#a + #b) #x', { a: isNumber, b: isNumber })

we should be able to apply in the following way

assert.equal(applyRule(rule, '2 x + 3 x'), '5 x')
kevinbarabash commented 7 years ago

Implemented in https://github.com/semantic-math/math-rules/commit/d6bdd9cb518269ee43f549415c412fee561b49ce.