4 ms·
It's definitely easier to parse programatically, but IMO it's a nightmare to read as a human. e.g. compare these expressions: (x+y)^2 = x^2 + 2xy + y^2 x y
by murderfs 3y ago
It's definitely easier to parse programatically, but IMO it's a nightmare to read as a human. e.g. compare these expressions:
(x+y)^2 = x^2 + 2xy + y^2
x y + 2 ^ = x 2 ^ 2 x y * * y 2 ^ + +
I find it nearly impossible to parse this without actually maintaining the stack in my mind.
- gumby 3y agoIt's exactly how you would do the calculation if you ran it by hand, unlike the regular algebraic notation. I am flabbergasted that anyone uses the latter, especially as for most of the history of mathematics calculation was done by hand!
- svachalek 3y agoI don't "run" x 2 ^ by hand and I don't think anyone does. Some people find different notations more intuitive and that's fine but whether it's prefix postfix or infix, it's still an abstraction.
- gumby 3y ago> I don't "run" x 2 ^ by hand and I don't think anyone does Of course everyone evaluates expressions symbolically: in code review, when debugging, even when looking over an expression just after typing it to make sure it’s right.
- SR2Z 3y agoMany languages have different verb order - English is notionally SVO (subject-verb-object), while Hindi is SOV. That is probably much more related to why we use prefix/infix/postfix notation: because it maps to our native languages better.
- deleted 3y ago[deleted]
- jjav 3y ago> I find it nearly impossible to parse this without actually maintaining the stack in my mind. You don't write out RPN in a long sequence like that. I'm a devoted RPN advocate and seeing "x y + 2 ^ = x 2 ^ 2 x y * * y 2 ^ + +" is indeed difficult to parse. But that's not at all how you use RPN. You compute the problem going from smaller units to larger units getting intermediate results as you go and combining them. You'd never write out the sequence as you did and try to follow it after the fact.
- tonyarkles 3y agoI went through EE using an HP 49G+ and continue to this day using RPN in Emacs calc-mode. >> I find it nearly impossible to parse this without actually maintaining the stack in my mind. > You compute the problem going from smaller units to larger units getting intermediate results as you go and combining them That's totally it. I've tried doing infix/standard algebraic notation on a calculator and unless the screen is big enough to see all of your brackets you're almost certainly going to screw up one of the big terms in a fraction or something like that. I think a good different way of stating the "intermediate results" part is that instead of computing the solution from left to right you're computing the solution from the inside-out. By far the most satisfying part of doing computation in RPN is that moment at the end when you've got a big stack full of intermediate results and you just do that "+ + + + +" to add them all up and bam! Answer! Edit: I had two thoughts back-to-back after writing that. First thought: I do actually struggle sometimes with doing math in Lisp because prefix notation isn't a way that I'm used to doing math. Which led to "Hmmm... what if you did Lisp but with postfix notation instead of prefix notation" Second though: "Ohhh... that's Forth. And you don't need brackets at all..."
- thaumasiotes 3y ago> Ohhh... that's Forth. And you don't need brackets at all... You still need them if you want variadic functions. Symmetrically, you don't need parentheses in lisp if you don't want variadic functions, as long as you're willing to draw an explicit distinction between calling a function and referring to it. You might as well just make that distinction by using the parentheses, though.