The Emacs Calculator (2009)
nullprogram.com
nullprogram.com
[0] Emacs financial calculations: https://plus.google.com/+AndrewHyatt/posts/YdwsbNmZ4NL
[1] Index of Andrew Hyatt's emacs calc tutorials: https://blog.markhepburn.com/2013/12/07/andrew-hyatts-emacs-...
[2] Emacs Google Plus community: https://plus.google.com/communities/114815898697665598016
Since then I am practically a daily user.
It's not without downsides, and some simple workflows that seem common and trivial to me personally feel a bit awkward and contorting. For example, working with variables/equations, with that '=>' "operator", is rather strange. There also seems to be no support for hex numbers in 0x-prefixed lowercase notation, which makes it hard to impossible to just copy and paste hex numbers for programming. And while emacs-calc has a very impressive scientific unit system, often I just want to use unit prefixes, like u,m,M for micro,milli,Mega respectively, without having to resort to using actual physical units in my calculations (and then finding out again how to simplify appropriately).
I also almost don't use the trail at all, mostly because its navigation and actioning feels tedious and downright archaic, making me think that emacs-calc probably started out a few decades ago, with a specific, now outdated, terminal paradigm in mind.
But all in all, it's pretty impressive, and fills the role as my daily companion for quick, and sometimes more elaborate, computations well.
https://raw.githubusercontent.com/mnp/dotfiles/master/shared...
nickle has normal algebraic notation with arbitrary precision, configurable base input/output for every expression (very reminiscent of calc), math functions and C operators work out of the box. It has variables, as well as a simple c-like language for additional extensions.
If RPN is not for you, "nickle" is a perfect "bc" replacement which works as you would expect.
The only downside is that, like any advanced Emacs functionality, if you don't use it frequently you forget all the commands.
For the reason you mention, I need to get into the habit of using Calc for my quick calculations; right now, I usually use Google (ick, infix notation) or dc.
--
I'll give it a go.
I thought this was happening only to me... but I’ve ditched Vim and went Emacs 100% so it’s bit better now, since I’ve been stuck with using both for like a year.
I might buy another HP28 for the car. :D
http://www.speedcrunch.org/download.html even links to 32- and 64-bit prebuilt Qt binaries for Linux. Nice.
For computations such as 10+3, it's comparabale. But I give SpeedCrunch an dedge because it can compute "sin(pi/2)" out of the box.
I still can't wrap my brain around a RPN calculator well enough to use it productively (but boy howdy can I tell you how the stack engine works!). All the cool kids in physics class in the 80's were using HP's, and I felt left out even then. Never managed to make it work for myself.
It takes a little practice to start thinking postfix, but it's a relief to not consider order of operations, and tends to be a lot more consistent with how I do arithmetic in my head in the first place.
Normal (non-algebraic) calculators are inconsistent. To get "2+3", it's infix: 2, +, 3, =. To get "cos(45)" it's postfix: 45 cos (and no equals). And something like "cos(2+3)" is a mixture of both. RPN, is always the same, numbers first, then operators, and usually more keystroke efficient. Some operators take multiple arguments.
RPN also has the advantage of (rarely) needing a memory register, since the values can be left on the stack and accessed as they are needed.
Just prefix every expression with '
Algebraic formulas are great but beyond my typical reuse recall duration.
I wonder what edge cases I would run into designing one.
I was wondering how difficult it would be to make a common lisp or scheme, but with postfix syntax instead of prefix.
[10]> (defmacro rev (&rest forms)
`(progn ,@(mapcar (lambda (form)
(if (and (consp form) (rest form))
`(,(car (last form)) ,@(butlast form))
form))
forms)))
REV
[11]> (rev (1 1 +))
2
[12]> (rev (3 print) (1 1 +))
3
2A Lisp macro (rpn ...) could provide a DSL whereby all the forms in ... are recursively code walked and turned from a postfix notation into a regular Lisp notation.
You probably want the walker not to fiddle with expressions like '(a b c) quoted lists. That creates a special case to handle. You have to know that (quote (a b c)) is in a context where it is evaluated (which normally undergoes rpn to Lisp transformation) and so should be left alone. You don't want (quote z) being treated as RPN denoting (z quote)! Likewise, you don't want #'foo, which is (function foo) to be turned into (foo function).
So, basically, a code walker is needed which knows what is evaluated and what isn't, which leaves alone stuff that isn't evaluated, and also avoids RPN-to-lisp-transforming certain expressions that are evaluated.
".. it gives you more insight into your calculations than using the ‘algebraic’ systems used by other calculators and it keeps you and not your calculator (see Appendix D) in command of what is calculated."
Second reason, RPN systems are typically open: I or others can add operations. That’s pretty rare in an algebraic machine, though not completely nonexistent.
The classic example
3 + 4 7 + 8
----- + -----
5 + 6 9 + 2
Strait forward in RPN 3 ^ 4 + 5 ^ 6 + / 7 ^ 8 + 9 ^ 2 + / +I have to bake 7 pies...
7
and each pie takes 45min
7 45 *
=> 315
But I can fit 3 pies in the oven at a time
7 45 * 3 /
=> 105
Using infix notation, I would need to consider order of operations, and put operators before data, increasing the mental stack size.
Using a postfix calculator, I can just throw values onto the stack, and start consolidating them with operations.
I’m not sure :) I think it’s because the stack makes it easier to see the state of the calculation, whereas without RPN I have to keep more in my head and can’t see it.
Basically what thomastjeffrey said.
It tries to include features of a Casio scientific calculator, so includes things like statistics / regression (of selected block) and engineering notation display. It inserts underscores between every three digits for easier reading: 0.123_456
It is not reverse polish.
Well, some might call that a good definition of scope creep, but at this point I'm sure we're all well aware that even though Emacs might be called a text editor, that's not really all it is.
In the end it’s often less trouble to switch over to the browser window that’s already open anyway and copy and paste data between it and emacs.