2000-02-21 lisp方式的通用名称是完全带括号的表示法。这个 语法是表示树最直接的语法,但它不是唯一的选择。例如,可以通过简单地将第一个元素的语义最后移动到 来表示完全括号 表示法。你写(arg1 arg2 ... f)而不是通常的(f arg1 arg2)。 同样聪明,你可以在任何地方移动f仍然有意义。在 Mathematica中,他们将f放在paren前面,并使用square 括号代替。例如f [a,b,c],Sin [3],Map [f,list] ...等。父母面前的中的f使得传统意义更好,直到f本身为 列表然后我们会看到诸如f [a,b] [c,g [3,h]]之类的东西等等。它更糟糕 当有任意嵌套头部。 Mathematica中的预修复符号表示为?? ?? @ arga ?? 基本上是预修复在此上下文中的表示法将其限制为仅使用一个参数的 函数。更多的例子:a ?? f @ a @ b @ ca ?? 相当于一个?? f [a [b [c]]] a ??或者在lispy a ??(f(a(b c)))a ?? 修复后符号类似。在Mathematica中,例如 a ?? c // b // a // fa ??比如一个??列表[1,2,3] //新浪?在语法上是 相当于一个?? Sin [List [1,2,3]] a ??或者是一个Sin @ List [1,2,3] a ?? (和 它们在语义上相当于一个?? Map [Sin,List [1,2,3]] a ?? in Mathematica)用于修复符号,函数符号放在 的参数之间。在Mathematica中,通过将波浪符号夹在函数名称周围,修复符号的通用形式为 。例如 a ??加入[List [1,2],List [3,4]] a ??可写为??列表[1,2]〜加入〜 列表[3,4] a ??。 一般情况下,何时我们说C是一种in-fix符号语言,我们不是说 它是严格修复的,但是这种情况对于 $来说是一体的。 b $ b方便。事情就像一个?? i ++ a ??,a ?? ++ ia ??,a ?? for(;;)a ??,0x123, a ?? sprint(... %s ...,...)a ??,...是语法异想天开。 (也就是说,一个特殊的 语法汤) 例如在Mathematica中,除了 $ b $之外还有很多语法糖b上面提到的系统构造。例如,Plus [a,b,c] 可以用以下方式编写:a ??(a + b)+ ca ??或a ?? a + b + ca ??或者 a ??(a + b)~Plus~ca ?? 要点是某些功能如Plus被赋予了一个 特殊符号''+''具有特定的语法形式,以模拟 不规则且效率低但仍然易于理解的传统 表示法。再举一个例子:时间[a,b]也可以写成 a ?? a * ba ??或者只是一个?? Mathematica也有C语言的'b $ b常规的?? i ++ a ??,a ?? ++ ia ??,a ?? i + = 1a ??例如。 作为旁注,Perl的销售商为他们的口号感到自豪 不止一种方式在他们的广告中做到这一点特殊的语法糖但是 不知道在函数式语言(例如Mathematica,Haskell, Lisp)中有一致且通用的结构可以 在理论上和实践中,生成的语法变体远远超过ad hoc前缀Perl 。 (在lisps中,他们的权力语法变化 以宏的形式出现。)更重要的是,Perlers吵着 关于Perl的表现力?或多或少的无用语法 等级,但没有意识到语义表达是真正重要的。 - --- 这篇文章存档于: http://xahlee.org/UnixResource_dir/writ/notations.html Xah xa*@xahlee.org a ?? http://xahlee.org/ 解决方案 2006年3月15日22:20:52 -0800,Xah Lee < xa*@xahlee.org>写道, 引用或间接引用某人说: e。例如,in-fix 符号= E2 = 80 = 9C(3+(2 * 5))> 7 = E2 = 80 = 9D写为= E2 = 80 = 9C3 2 5 * + 7 > = = E2 = 80 = 9D,其中 并非李先生对反馈表现出很大的兴趣,但你 很好地坚持使用vanilla ASCII来获取你的记号通过 在新闻组中解开。 - 加拿大心灵产品,Roedy Green。 http://mindprod.com Java自定义编程,咨询和指导。 ""并不是说Lee先生对反馈有过多的兴趣,但是你很好地坚持了b $ b通过 在新闻组中解读你的符号香草ASCII。""" 这是21世纪,所以不得不这样做才能激发灵感某种类型 获得了很好的反Unix咆哮... :) SamFeltus写道:""并不是李先生对反馈有过多的兴趣,但是你很好地坚持使用vanilla ASCII来获取你的记号 unmangled on newsgroups。"" 这是21世纪,所以必须要做到这一点,激发一些好的反Unix咆哮...... :) 不反Unix. 反使用适当的数据类型 - 手头的任务。 The Concepts and Confusions of Pre-fix, In-fix, Post-fix and FullyFunctional NotationsXah Lee, 2006-03-15Let me summarize: The LISP notation, is a functional notation, and isnot a so-called pre-fix notation or algebraic notation.Algebraic notations have the concept of operators, meaning, symbolsplaced around arguments. In algebraic in-fix notation, differentsymbols have different stickiness levels defined for them. e.g.a??3+2*5>7a?? means a??(3+(2*5))>7a??. The stickiness of operatorsymbols are normally called a??Operator Precedencea??. It is done bygiving a order specification for the symbols, or equivalently, giveeach symbol a integer index, so that for example if we havea??aa??ba??ca??, we can unambiguously understand itto mean one ofa??(aa??b)a??ca?? or a??aa??(ba??c)a??.In a algebraic post-fix notation known as Polish Notation, there needsnot to have the concept of Operator Precedence. For example, the in-fixnotation a??(3+(2*5))>7a?? is written as a??3 2 5 * + 7 >a??, where theoperation simply evaluates from left to right. Similarly, for a pre-fixnotation syntax, the evaluation goes from right to left, as in a??> 7+* 5 2 3a??.While functional notations, do not employ the concept of Operators,because there is no operators. Everything is a syntactically aa??functiona??, written as f(a,b,c...). For example, the sameexpression above is written as a??>( +(3, *(2,5)), 7)a?? ora??greaterThan( plus(3, times(2,5)), 7)a??.For lisps in particular, their fully functional notation ishistorically termed sexp (short for S-Expression, where S stands forSymbolic). It is sometimes known as Fully Parenthesized Notation. Forexample, in lisp it would be (f a b c ...). In the above example it is:a??(> (+ 3 (* 2 5)) 7)a??.The common concepts of a??pre-fix, post-fix, in-fixa?? are notions inalgebraic notations only. Because in Full Functional Notation, there isno concept of where one places the a??operatora?? or function. There isalways just a single position given with explicitly enclosed arguments.Another way to see that lisp notation are not a??prea?? anything, is byrealizing that the a??heada?? f in (f a b c) can be defined to beplaced anywhere. e.g. (a b c f) or even (a f b c), and it''s still notpre- or in- or post- anything. For example, in the languageMathematica, f(a b c) would be written as f[a,b,c] where the argumentenclosure symbols is the square bracket instead of parenthesis, andargument separator is comma instead of space, and the function symbol(or head) is placed in outside and in front of the argument enclosuresymbols.The reason for the misconception that lisp notations are a??pre-fixa??is because the head appears before the enclosed arguments. Sucha??pre-fixa?? has no signifance in Full Functional Notation systems andcan only engender confusion in the Algebraic Pre-fix Notation systemswhere the term has significance.2000-02-21The common name for the lisp way is Fully Parenthesized Notation. Thissyntax is the most straightforward to represent a tree, but it''s notthe only choice. For example, one could have Fully ParenthesizedNotation by simply moving the semantics of the first element to thelast. You write (arg1 arg2 ... f) instead of the usual (f arg1 arg2).Like wise, you can essentially move f anywhere and still make sense. InMathematica, they put the f in front of the paren, and use squarebrackets instead. e.g. f[a,b,c], Sin[3], Map[f,list] ... etc. The f infront of parent makes better conventional sense until f is itself alist which then we''ll see things like f[a,b][c, g[3,h]] etc. It''s worsewhen there are arbitrary nesting of heads.A pre-fix notation in Mathematica is represented as a??f@arga??.Essentially, a pre-fix notation in this context limits it to uses forfunction that has only one argument. More example: a??f@a@b@ca?? isequivalent to a??f[a[b[c]]]a?? or in lispy a??(f (a (b c)))a??. Apost-fix notation is similar. In Mathematica it is, e.g.a??c//b//a//fa??. For example a??List[1,2,3]//Sina?? is syntacticallyequivalent to a??Sin[List[1,2,3]]a?? or a??Sin@List[1,2,3]a??. (andthey are semantically equivalent to a??Map[Sin, List[1,2,3]]a??inMathematica) For in-fix notation, the function symbol is placed betweenits arguments. In Mathematica, the generic form for in-fix notation isby sandwiching the tilde symbol around the function name. e.g.a??Join[List[1,2],List[3,4]]a?? can be written as a??List[1,2] ~Join~List[3,4]a??.In general, when we say C is a in-fix notation language, we don''t meanit''s strictly in-fix but the situation is one-size-fits-all forconvenience. Things like a??i++a??, a??++ia??, a??for(;;)a??, 0x123,a??sprint(...%s...,...)a??, ... are syntax whimsies. (that is, a ad hocsyntax soup)In Mathematica for example, there is quite a lot syntax sugars besidethe above mentioned systimatic constructs. For instance, Plus[a,b,c]can be written in the following ways: a??(a+b)+ca?? or a??a+b+ca?? ora??(a+b)~Plus~ca??The gist being that certain functions such as Plus is assigned aspecial symbol ''+'' with a particular syntax form to emulate theirregular and inefficient but nevertheless well-understood conventionalnotation. For another example: Times[a,b] can be also written asa??a*ba?? or just a??a ba??. Mathematica also have C language''sconvention of a??i++a??, a??++ia??, a??i+=1a?? for examples.As a side note, the Perl mongers are proud of their slogan of There AreMore Than One Way To Do It in their gazillion ad hoc syntax sugars butunaware that in functional languages (such as Mathematica, Haskell,Lisp) that there are consistent and generalized constructs that cangenerate far far more syntax variations than the ad hoc prefixed Perlboth in theory AND in practice. (in lisps, their power syntax variationcomes in the guise of macros.) And, more importantly, Perlers clamorabout Perl''s a??expressivenessa?? more or less on the useless syntaxlevel but don''t realize that semantic expression is what''s reallyimportant.----This post is archived at: http://xahlee.org/UnixResource_dir/writ/notations.htmlXah xa*@xahlee.orga?? http://xahlee.org/ 解决方案 On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <xa*@xahlee.org> wrote,quoted or indirectly quoted someone who said : e. For example, the in-fixnotation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >==E2=80=9D, where theNot that Mr. Lee has ever shown much interest in feedback, but youpretty well have stick to vanilla ASCII to get your notation throughunmangled on newsgroups.--Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching."""Not that Mr. Lee has ever shown much interest in feedback, but youpretty well have stick to vanilla ASCII to get your notation throughunmangled on newsgroups."""It is the 21st century, so having to do that oughta inspire some sortof well earned anti Unix rant...:) SamFeltus wrote: """Not that Mr. Lee has ever shown much interest in feedback, but you pretty well have stick to vanilla ASCII to get your notation through unmangled on newsgroups.""" It is the 21st century, so having to do that oughta inspire some sort of well earned anti Unix rant... :)Not anti-Unix.Anti-failure-to-use-appropriate-datatypes-for-the-task-at-hand. 这篇关于Xah的Edu角落:预修复,修复,修复后和全功能符号的概念和混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-09 22:47