我目前正在开发Shunting Yard Algorithm的修改版本,该版本可以使用变量,但是我不知道如何使它起作用.例如,我希望算法重新编写2 *(2x + 5)-5到4x +5.是否有任何想法/指向已经实现的算法的链接?
I'm currently working on a modified version of the Shunting Yard Algorithm that would work with variables, but I cant figure out how to get it to work. For example, I would want the algorithm to re-write 2 * (2x + 5) - 5 to 4x + 5. Any ideas / links to already implemented algorithms that does this already?
推荐答案
--/\* 5/\2 +/\* 5/\2倍5.定义代数规则并将其应用于树.例如,一条规则能够将 2 节点与 2 * x + 5 子树相乘".
- / \ * 5 / \ 2 + / \ * 5 / \ 2 x 5. Define and apply algebraic rules to the tree. For example, a rule to be able to 'multiply' the 2 node with the 2 * x + 5 subtree.
更多推荐
带变量的调车场算法
发布评论