简体   繁体   English

.Net中的符号操作

[英]Symbolic Manipulation Within .Net

I recall an assigment in one of my computer science classes that involved symbolic differentiation with Common Lisp. 我回想起我的一门计算机科学课程中的一项内容,其中涉及Common Lisp的符号区分。 The properties of common lisp allows you to take an equation and apply symbolic manipulation. common lisp的属性允许您采用方程式并应用符号操作。

My question is, are there any libraries and programming languages within the .Net framework that allows symbolic manipulation? 我的问题是,.Net框架中是否有任何允许符号操作的库和编程语言? I'd prefer using C# to solve this. 我更喜欢使用C#来解决这个问题。 I've already looked at this link but it doesn't give concrete answers. 我已经看过链接,但没有给出具体答案。

Let me explain my situation in more detail. 让我更详细地说明我的情况。

Suppose I have conditional formula, the entirety as a String. 假设我有条件公式,整体为String。 Each name 1DPZ_XY represents an integer variable. 每个名称1DPZ_XY代表一个整数变量。 Each of these variables have already been assigned a value. 这些变量中的每一个都已分配了一个值。

"
{
1DPZ_a2 = (2 OR 3)
AND
(
1DPZ_a6 = 9
OR 
1DPZ_b3 = (3 OR 7)
AND 
(
1DPZ_b4 = 8
OR
1DPZ_b5 = 2
OR
1DPZ_b6 = (4 OR 2)
)
)
}
"

Obviously this formula will return either true or false. 显然,此公式将返回true或false。 How can I convert this String logic into a if-statement I can interact with? 如何将这个String逻辑转换为可以与之交互的if语句?

You can parse your string and build a .NET Expression Tree from it. 您可以解析字符串并从中构建一个.NET表达式树 You can then manipulate that expression tree to evaluate it, print it, or transform it (typically using an ExpressionVisitor ). 然后,您可以操纵该表达式树以对其进行评估,打印或转换(通常使用ExpressionVisitor )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM