CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 107 users online: 6 members, 69 guests and 32 bots.
Members: don, Kllrnohj, matrefeytontias, shmibs.
Bots: VoilaBot (3), Spinn3r (1), MSN/Bing (1), Magpie Crawler (4), VoilaBot (3), Googlebot (14), Googlebot (5), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget

I love...
Prefix! (* 3 (+ 1 2))
27%
 27%  [ 3 ]
Infix! (3 * (1 + 2))
27%
 27%  [ 3 ]
Postfix! ((1 2 +) 3 *)
0%
 0%  [ 0 ]
RPN! (3 1 2 + *)
27%
 27%  [ 3 ]
I had never heard of these before.
18%
 18%  [ 2 ]
Total Votes : 11

Author Message
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55761
Location: Earth, Sol, Milky Way

Posted: 07 Nov 2011 11:24:10 pm    Post subject: Expression-Operator Ordering

Are you a die-hard RPN fan? Can you not live without LISP? Do those both disgust you? Let's duke it out, tell us what you like (and why! The why is very important. No one-word posts).

If you're not familiar with these concepts, read up on reverse Polish notation (RPN) (postfix notation), Polish notation (prefix notation), and infix notation.
_________________


Back to top
Ashbad


... I think redheaded girls are kind of cool


Joined: 01 Dec 2010
Posts: 2418
Location: Stomp Stomp Stomp, The Idiot Convention

Posted: 07 Nov 2011 11:28:21 pm    Post subject: Re: Expression-Operator Ordering

I can't wrap my mind around RPN well, but prefix notation seems fun and intuitive, in a sense, because I feel it's thinking more in terms of robust functions than just plain old operators. Of course, I'm best with infix notation, because I of course, learned it first, like virtually everyone else has. However, when you think about it, if you weren't used to it, it would seem a bit strange to put an operator between two numbers, rather than before or in a logical order of operations.

KermMartian wrote:
No one-word posts.


Yes I do.
_________________
-Ashbad
Back to top
Qwerty.55


Expert


Joined: 08 Dec 2010
Posts: 613

Posted: 07 Nov 2011 11:30:15 pm    Post subject:

As much as I hate actually using RPN in real life, almost all of my programs involving equation parsing use RPN for the internal representations of functions. It minimizes the total characters in the representation string while remaining unambiguous, and ridiculously easy to convert to a syntax tree. For computers, it is the best expression ordering syntax.
_________________
∂²Ψ -(2m(V(x)-E)Ψ
----- = -------------
∂x² ℏ²Ψ
Back to top
_player1537


Guru-in-Training


Joined: 25 Nov 2009
Posts: 2958

Posted: 07 Nov 2011 11:31:12 pm    Post subject:

Prefix, of course. I don't have any reasons except: it makes you think, and when you come back to it later, it's easier to tell what you meant. I would say that you don't have to include extra parentheses to make sure it interprets (3+2)*4 correctly, but the same statement in Scheme would be (* (+ 3 2) 4), which uses twice as many characters and even more spaces.

That said, I also enjoy RPN for a similar reason, it really pushes your mind to behave like a stack. When I was working on a stack-based programming language, just trying to wrap my head around code that would test the interpreter was extremely difficult.

Of course, infix notation is the easy one, but I find that I still add many spaces to make sure it looks good, and that I'll be able to read it later.
_________________
http://tanner.myserverathome.com
Back to top
christop


Power User


Joined: 09 Mar 2011
Posts: 385
Location: Arizona, USA

Posted: 22 Nov 2011 12:42:36 am    Post subject:

Ummm, RPN is Postfix notation (though you already know that, I'm sure).

RPN is indeed very handy with asm programming: push operands onto the stack (possibly treating one or more registers as a virtual top of the stack) and then perform operations on the values on the top.

Prefix notation is also pretty common in many (if not most) languages, such as when calling functions:

Code:
multiply(3, add(1, 2))

Of course, some languages like Lisp use Prefix notation for everything.

Then there's good ol' Infix notation. Everyone learns that in math class.

Where's the "All of the above" option? Smile
_________________
Christopher Williams
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.031844 seconds.