Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations (http://www.velocityreviews.com/forums/t897026-xahs-edu-corner-the-concepts-and-confusions-of-pre-fix-in-fix-post-fix-and-fully-functional-notations.html)

Xah Lee 03-16-2006 06:20 AM

Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully
Functional Notations

Xah Lee, 2006-03-15

Let me summarize: The LISP notation, is a functional notation, and is
not a so-called pre-fix notation or algebraic notation.

Algebraic notations have the concept of operators, meaning, symbols
placed around arguments. In algebraic in-fix notation, different
symbols have different stickiness levels defined for them. e.g.
“3+2*5>7” means “(3+(2*5))>7”. The stickiness of operator
symbols are normally called “Operator Precedence”. It is done by
giving a order specification for the symbols, or equivalently, give
each symbol a integer index, so that for example if we have
“a⊗b⊙c”, we can unambiguously understand itto mean one of
“(a⊗b)⊙c” or “a⊗(b⊙c)”.

In a algebraic post-fix notation known as Polish Notation, there needs
not to have the concept of Operator Precedence. For example, the in-fix
notation “(3+(2*5))>7” is written as “3 2 5 * + 7 >”, where the
operation simply evaluates from left to right. Similarly, for a pre-fix
notation syntax, the evaluation goes from right to left, as in “> 7+
* 5 2 3”.

While functional notations, do not employ the concept of Operators,
because there is no operators. Everything is a syntactically a
“function”, written as f(a,b,c...). For example, the same
expression above is written as “>( +(3, *(2,5)), 7)” or
“greaterThan( plus(3, times(2,5)), 7)”.

For lisps in particular, their fully functional notation is
historically termed sexp (short for S-Expression, where S stands for
Symbolic). It is sometimes known as Fully Parenthesized Notation. For
example, in lisp it would be (f a b c ...). In the above example it is:
“(> (+ 3 (* 2 5)) 7)”.

The common concepts of “pre-fix, post-fix, in-fix” are notions in
algebraic notations only. Because in Full Functional Notation, there is
no concept of where one places the “operator” or function. There is
always just a single position given with explicitly enclosed arguments.

Another way to see that lisp notation are not “pre” anything, is by
realizing that the “head” f in (f a b c) can be defined to be
placed anywhere. e.g. (a b c f) or even (a f b c), and it's still not
pre- or in- or post- anything. For example, in the language
Mathematica, f(a b c) would be written as f[a,b,c] where the argument
enclosure symbols is the square bracket instead of parenthesis, and
argument separator is comma instead of space, and the function symbol
(or head) is placed in outside and in front of the argument enclosure
symbols.

The reason for the misconception that lisp notations are “pre-fix”
is because the head appears before the enclosed arguments. Such
“pre-fix” has no signifance in Full Functional Notation systems and
can only engender confusion in the Algebraic Pre-fix Notation systems
where the term has significance.

2000-02-21

The common name for the lisp way is Fully Parenthesized Notation. This
syntax is the most straightforward to represent a tree, but it's not
the only choice. For example, one could have Fully Parenthesized
Notation by simply moving the semantics of the first element to the
last. You write (arg1 arg2 ... f) instead of the usual (f arg1 arg2).

Like wise, you can essentially move f anywhere and still make sense. In
Mathematica, they put the f in front of the paren, and use square
brackets instead. e.g. f[a,b,c], Sin[3], Map[f,list] ... etc. The f in
front of parent makes better conventional sense until f is itself a
list which then we'll see things like f[a,b][c, g[3,h]] etc. It's worse
when there are arbitrary nesting of heads.

A pre-fix notation in Mathematica is represented as “f@arg”.
Essentially, a pre-fix notation in this context limits it to uses for
function that has only one argument. More example: “f@a@b@c” is
equivalent to “f[a[b[c]]]” or in lispy “(f (a (b c)))”. A
post-fix notation is similar. In Mathematica it is, e.g.
“c//b//a//f”. For example “List[1,2,3]//Sin” is syntactically
equivalent to “Sin[List[1,2,3]]” or “Sin@List[1,2,3]”. (and
they are semantically equivalent to “Map[Sin, List[1,2,3]]”in
Mathematica) For in-fix notation, the function symbol is placed between
its arguments. In Mathematica, the generic form for in-fix notation is
by sandwiching the tilde symbol around the function name. e.g.
“Join[List[1,2],List[3,4]]” can be written as “List[1,2] ~Join~
List[3,4]”.

In general, when we say C is a in-fix notation language, we don't mean
it's strictly in-fix but the situation is one-size-fits-all for
convenience. Things like “i++”, “++i”, “for(;;)”, 0x123,
“sprint(...%s...,...)”, ... are syntax whimsies. (that is, a ad hoc
syntax soup)

In Mathematica for example, there is quite a lot syntax sugars beside
the above mentioned systimatic constructs. For instance, Plus[a,b,c]
can be written in the following ways: “(a+b)+c” or “a+b+c” or
“(a+b)~Plus~c”

The gist being that certain functions such as Plus is assigned a
special symbol '+' with a particular syntax form to emulate the
irregular and inefficient but nevertheless well-understood conventional
notation. For another example: Times[a,b] can be also written as
“a*b” or just “a b”. Mathematica also have C language's
convention of “i++”, “++i”, “i+=1” for examples.

As a side note, the Perl mongers are proud of their slogan of There Are
More Than One Way To Do It in their gazillion ad hoc syntax sugars but
unaware that in functional languages (such as Mathematica, Haskell,
Lisp) that there are consistent and generalized constructs that can
generate far far more syntax variations than the ad hoc prefixed Perl
both in theory AND in practice. (in lisps, their power syntax variation
comes in the guise of macros.) And, more importantly, Perlers clamor
about Perl's “expressiveness” more or less on the useless syntax
level but don't realize that semantic expression is what's really
important.
----
This post is archived at:
http://xahlee.org/UnixResource_dir/writ/notations.html

Xah
xah@xahlee.org
http://xahlee.org/


Roedy Green 03-16-2006 06:17 PM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 
On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <xah@xahlee.org> wrote,
quoted or indirectly quoted someone who said :

>e. For example, the in-fix
>notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
>=E2=80=9D, where the


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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

SamFeltus 03-16-2006 11:31 PM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 
"""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...

:)


Xah Lee 03-17-2006 01:03 AM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 
Xah Lee wrote:
« The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully
Functional Notations
http://xahlee.org/UnixResource_dir/writ/notations.html »

A side note: the terminology “Algebraic” Notation is a misnomer. It
seems to imply that such notations have something to do with the branch
of math called algebra while other notation systems do not. The reason
the name Algebraic Notation is used because when the science of algebra
was young, around 1700s mathematicians are dealing with equations using
symbols like “+ × =” written out similar to the way we use them
today. This is before the activities of systimatic investigation into
notation systems as necessitated in the studies of logic in 1800s or
computer languages in 1900s. So, when notation systems are actually
invented, the conventional way of infixing “+ × =” became known as
algebraic because that's what people think of when seeing them.

Xah
xah@xahlee.org
http://xahlee.org/


Fuzzyman 03-17-2006 08:58 AM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 

Roedy Green wrote:
> On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <xah@xahlee.org> wrote,
> quoted or indirectly quoted someone who said :
>
> >e. For example, the in-fix
> >notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
> >=E2=80=9D, where the

>
> 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.


Hmmm... it displays fine via google groups. Maybe it's the reader which
is 'non-compliant' ?

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml



> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.



Dinko Tenev 03-17-2006 09:09 AM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 
Roedy Green wrote:
> On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <xah@xahlee.org> wrote,
> quoted or indirectly quoted someone who said :
>
> >e. For example, the in-fix
> >notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
> >=E2=80=9D, where the

>
> 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.


That would be one of my last concerns with Mr. Lee's postings.

If only someone could persuade this guy to stay away from CS...


Timo Stamm 03-17-2006 10:22 AM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix,Post-fix and Fully Functional Notations
 
Fuzzyman schrieb:
> Roedy Green wrote:
>> On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <xah@xahlee.org> wrote,
>> quoted or indirectly quoted someone who said :
>>
>>> e. For example, the in-fix
>>> notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
>>> =E2=80=9D, where the

>> 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.

>
> Hmmm... it displays fine via google groups. Maybe it's the reader which
> is 'non-compliant' ?



Other charsets than US-ASCII are widely accepted in non-english
newsgroups as long as the charset is properly declared.

Xah's posting was properly encoded and will display fine in every decent
newsreader.


Timo

axel@white-eagle.invalid.uk 03-17-2006 01:06 PM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 
In comp.lang.perl.misc Timo Stamm <timo.stamm@arcor.de> wrote:
> Fuzzyman schrieb:
>> Roedy Green wrote:
>>> On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <xah@xahlee.org> wrote,
>>> quoted or indirectly quoted someone who said :
>>>
>>>> e. For example, the in-fix
>>>> notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
>>>> =E2=80=9D, where the
>>> 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.


>> Hmmm... it displays fine via google groups. Maybe it's the reader which
>> is 'non-compliant' ?


> Other charsets than US-ASCII are widely accepted in non-english
> newsgroups as long as the charset is properly declared.


> Xah's posting was properly encoded and will display fine in every decent
> newsreader.


It is not just the question of the newsreader, it is also a question of whether
the character set/font being used is capable of displaying the characters
concerned.

Axel


Timo Stamm 03-17-2006 02:29 PM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix,Post-fix and Fully Functional Notations
 
axel@white-eagle.invalid.uk schrieb:
> In comp.lang.perl.misc Timo Stamm <timo.stamm@arcor.de> wrote:
>> Other charsets than US-ASCII are widely accepted in non-english
>> newsgroups as long as the charset is properly declared.

>
>> Xah's posting was properly encoded and will display fine in every decent
>> newsreader.

>
> It is not just the question of the newsreader, it is also a question of whether
> the character set/font being used is capable of displaying the characters
> concerned.


A character set doesn't display characters, it specifies the coupling of
a character (grapheme) and its representation in a data format (number).

Because the specification of internet text messages only allows 7 bit
ASCII, Multipurpose Internet Mail Extensions have been introduced. They
define, for example, the quoted-printable transfer encoding.

Xah's posting properly declared a quoted-printable transfer encoding and
the UTF-8 charset. There were no unspecified characters in the message,
it was absolutely adhering to the recognized standards.


If this message doesn't display properly on your system - because your
newsreader doesn't know how to decode quoted printable or because your
operating system lacks a font to display the characters, this may be a
problem. But it's your newsreader or your OS that is broken or not up to
date.

BTW, the newsreader you are using should handle the posting fine.


Timo

Roedy Green 03-17-2006 07:16 PM

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations
 
On 17 Mar 2006 00:58:55 -0800, "Fuzzyman" <fuzzyman@gmail.com> wrote,
quoted or indirectly quoted someone who said :

>Hmmm... it displays fine via google groups. Maybe it's the reader which
>is 'non-compliant' ?

I am using Agent. You configure your database with an encoding,
which is by default the platform encoding, not UTF-8. I have just
flipped it over to UTF-8. We'll see if that makes Xah's future UTF-8
messages more readable.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.


All times are GMT. The time now is 05:58 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.