我怎么读一个方程式 [英] How can i read an equation

查看:69
本文介绍了我怎么读一个方程式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有这个数学方程 p = x * x * x + 2 * x * x + x + 10 。我意识到每次我改变数学方程式时我都必须在程序中重写新方程式然后我必须重新构建它。

我的问题是这个

我可以在像 InputFile.txt 这样的文件中写下方程式,然后从该文件中读取方程式作为字符串然后在程序内部我想要获得方程式的值和/ b $ b将它赋予变量 p

解决方案

它实际上是可能的。有一些库可以实现这一功能。看看下面的CP文章。



MathParser - 数学公式解析器 [ ^ ]

带插件的可扩展数学表达式解析器 [ ^ ]

方程分析器(解析器) [ ^ ]

将数学方程转换为C# [ ^

ÿ你可以使用C#本身在一个单独的程序集中编译代码并在你的代码中使用。

这可能会得到很好的回报,但需要花费大量的精力进行编程。



在我过去的解决方案中你会发现很多拘留(实际上是应用程序的骨架):

创建使用可重新加载插件的WPF应用程序...... [ ^ ],

AppDomain拒绝加载程序集 [ ^ ],
使用CodeDom生成代码 [ ^ ]。



-SA


Assume i have this math equation p=x*x*x+2*x*x+x+10. i realized that every time i change the math equation i have to rewrite the new equation in the program then i have to rebuild it again.
my question is this
can i write the equation inside file like InputFile.txt then read the equation from that file as a string then
inside the program i do some think to obtain the value of the equation and assigne it to variable p
?

解决方案

Its actually possible. There are some libraries which does this functionality. Have a look at the following CP articles.

MathParser - Math Formula Parser[^]
An extensible math expression parser with plug-ins[^]
Equation Analyzer(Parser)[^]
Converting math equations to C#[^]


You can use C# itself to compile your code in a separate assembly and use in your code.
This may pay off very well, but will require considerable effort in programming.

You will find a lot of detain (actually, a skeleton of the application) in my past solutions:
Create WPF Application that uses Reloadable Plugins...[^],
AppDomain refuses to load an assembly[^],
code generating using CodeDom[^].

—SA


这篇关于我怎么读一个方程式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆