5 ms·
It's just training. Buy and use a RPN calculator and lisp suddenly seems normal. (To answer your question directly, yes it's readable. You learn to look past t
by evilduck 9y ago
It's just training. Buy and use a RPN calculator and lisp suddenly seems normal.
(To answer your question directly, yes it's readable. You learn to look past the syntax in lisp the same as you stop reading semi-colons and curly braces in other languages)
- deleted 9y ago[deleted]
- gkya 9y agoM-x calc!
- xelxebar 9y agoOr if you're a fan of cli tools, check out dc!
- unkown-unknowns 9y agoI use dc every now and then but I wish it'd do decimal math by default. 9 35 5 12 *+/p Furthermore I think it's strange that the order of the operands of the division operator is divisor as top-most value on the stack and dividend as second top-most value and not the other way around. For example, to me it'd feel more natural if 3 5 /p was equivalent to 5 / 3 in infix notation, not 3 / 5 Because when I think of a fraction I think of it as "dividend over divisor". Edit: Actually I Googled and it makes sense now. I've been focusing on what's on the stack but if we look at what is provided as input instead then it becomes "calculate dividend, calculate divisor, divide". Longer example which shows this: Algebraic expression (4 + 2 * 5) / (1 + 3 * 2) RPN 4 2 5 * + 1 3 2 * + /
- boomlinde 9y agoSome distributions use a ".dcrc" or some such that will be executed on startup. Dump "3k" in there to set the precision. The order of the operands of non-commutative operators reflects popular RPN calculators and Forth. You can swap the topmost elements of the stack with "r", for example "3 5r/p"
- vram22 9y agoFor people who prefer infix, bc was/is a more user-friendly wrapper over dc. See: $ man bc and https://en.wikipedia.org/wiki/Bc_(programming_language) https://en.wikipedia.org/wiki/Bc_(programming_language) I normally invoke it with: $ bc -l to get more digits of precision after the decimal point (see Wikipedia page). Excerpt: [ bc first appeared in Version 6 Unix in 1975 and was written by Robert Morris and Lorinda Cherry of Bell Labs. bc was preceded by dc, an earlier arbitrary-precision calculator written by the same authors. dc could do arbitrary-precision calculations, but its reverse Polish notation (RPN) syntax was inconvenient for users, and therefore bc was written as a front-end to dc. bc was a very simple compiler (a single yacc source file with a few hundred lines), which converted the new, C-like, bc syntax into dc's postfix notation and piped the results through dc. ] Note that GNU bc is no longer a front-end to dc: [ In 1991, POSIX rigorously defined and standardized bc. Two implementations of this standard survive today: The first is the traditional Unix implementation, a front-end to dc, which survives in Unix and Plan 9 systems. The second is the free software GNU bc, first released in 1991 by Philip A. Nelson. The GNU implementation has numerous extensions beyond the POSIX standard and is no longer a front-end to dc (it is a bytecode interpreter). ] Also, you can pipe the standard output of any other (filter) command into bc, and likewise, pipe bc's output to any other filter.
- chx 9y agoNormal? It's upside down! I am a die hard RPN fan, started with a HP 32S when I was 14 years old almost three decades ago, upgraded to a HP 48G a few years old (well, kind of a 48G - 48GX hybrid, a friend of mine and I hacked it to 512K SRAM, gosh, hand soldering those little TSOP legs, brrr, we just stacked them chips and ran the data legs together, those were the days). But this is alien and hard to read, RPN should be _reverse_ polish notation, you know? And + 1 2 3 is weird because it makes + a three argument operation, or I guess in this case, variable number of arguments. 1 2 3 + + is easy to read and understand :)