为什么我们需要preFIX,后缀符号 [英] Why do we need prefix, postfix notation
问题描述
我知道他们每个人可以转换到另一个,但从来没有真正了解他们的应用程序。通常缀操作非常可读的,但如果它失败,从而导致了preFIX和后缀符号
I know how each of them can be converted to one another but never really understood what their applications are. The usual infix operation is quite readable, but where does it fail which led to inception of prefix and postfix notation
推荐答案
中缀表示法很容易阅读的人类的,而pre型/后缀符号更易于解析一台机器。在pre型/后缀符号的一大优势是,永远不会出现像运营商precedence任何问题。
Infix notation is easy to read for humans, whereas pre-/postfix notation is easier to parse for a machine. The big advantage in pre-/postfix notation is that there never arise any questions like operator precedence.
例如,考虑缀EX pression 1#2 $ 3
。现在,我们不知道这些经营者的意思,所以有两种可能的相应后缀EX pressions: 1 2#3 $
和 1 2 3 $#
。如果不知道管使用这些运营商的规则,缀EX pression基本上是毫无价值的。
For example, consider the infix expression 1 # 2 $ 3
. Now, we don't know what those operators mean, so there are two possible corresponding postfix expressions: 1 2 # 3 $
and 1 2 3 $ #
. Without knowing the rules governing the use of these operators, the infix expression is essentially worthless.
或者,说得更为通用的术语:有可能从pre型/后缀EX pression恢复原来的(解析)树没有任何额外的知识,但同样是不正确的对于缀EX pressions。
Or, to put it in more general terms: it is possible to restore the original (parse) tree from a pre-/postfix expression without any additional knowledge, but the same isn't true for infix expressions.
这篇关于为什么我们需要preFIX,后缀符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!