Arithmetic expression simplifier in Clojure

馋奶兔 提交于 2019-12-20 06:27:32

问题


I want of create simplifier of arithmetic expressions in Clojure, and I am new to this language.
So for ex.: in: "2x + 6y - (12 + (5x - 3y)) + 4" simplified: "- 3x + 9y - 8".

So my attempt is to parse expression with regexp into hierarchical vector of nested expressions like this: ["5x-3y" "12 + <?>" "2x + 6y - <?> + 4"] ;; <?> is evaluated item from previous step and then evaluate them in sequence.

I am feeling like it's hack, some advice would be helpful.

来源:https://stackoverflow.com/questions/51905562/arithmetic-expression-simplifier-in-clojure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!