6 ms·
I've had to work with reverse polish notation on a regular basis for years yet to this day I still can't get my head around even the most basic expressions with
by Stevvo 4y ago
I've had to work with reverse polish notation on a regular basis for years yet to this day I still can't get my head around even the most basic expressions with more than a couple of operators. I've resorted to writing the required code in regular notation then using a script to reorder it to RPN; If I can't 'get it' after hundreds of hours I'm never going to 'get it'.
- imglorp 4y agoSomething that really clicked was taking physics and chemistry classes with an HP RPN calculator. You typically rearrange your equations, factor label, substitute values, and calculate: plug-and-chug. We had races and the HP's always beat the TI's and Casio's because you don't need to mess with parens. You might enter a parenthesized expression first and then work outwards.
- martyalain 4y agoA long time ago I was able to write on my HP67 a complete program for calculating the compression, tension and bending forces of a continuous beam on supports (for example a railway rail on sleepers), applying the equations I learned in my engineering school. In fact it was the first time I understood something about this equation. Until I translated it into code I only knew the music, not the details. That's why, when I explore a code, here the evaluation of an RPN expression, I try to keep the foundations to a minimum. The minimum minimorum is the lambda-calculus. Many code examples use the subtleties of this or that language, with the drawback of hiding the fundamental structure of the algorithm. For these reasons I prefer the "list" version to the "array" version. Basically nothing else than the three fundamental "cons, car, cdr". I am interested in your opinion.
- martyalain 4y agoAt the end of the 70's I bought (very expensive) a HP67 and discovered the inverse Polish notation, "1 2 +". Much later I came across LISP and discovered prefixed parenthesized expressions, {+ 1 2}, i.e. direct polish notation with parentheses. Then I thought that an HTML expression like "< b>< i>< u>Hello World< /u>< /i>< /b>", written in the right way, would be better written in a LISPsish style, {b {i {u Hello World}}}, no more boring with the order of closing brackets. Finally I found that writing {b 1 2 3 4 5 6} displayed "1 2 3 4 5 6" in bold, writing {* 1 2 3 4 5 6} displayed the product, "720", and writing {b {* 1 2 3 4 5 6}} displayed "720" in bold. This made me want to write a language about these findings and its current state is here http://lambdaway.free.fr/lambdawalks/ http://lambdaway.free.fr/lambdawalks/.
- joeframbach 4y agoThis is basically what jsx transpiles to, but in JavaScript. Like this: https://www.npmjs.com/package/hyperscript https://www.npmjs.com/package/hyperscript. h('b', h('i', h('u', 'Hello world')));
- martyalain 4y agoThe big difference is that in lambdatalk you just write {b {i {u Hello world}}}. Without quoting b, i, u and Hello world. As in pure HTML!