Hacker News new | ask | show | jobs
by qguv 4145 days ago
I stopped using infix calculators a while back in favor of RPN/stack calculators (dc) because I get quite tired of parens. Is the program structured such that this change would be simple? Otherwise I feel like this is simply yet another CLI calculator.
5 comments

People interested in this calculator might be interested in my project, which is written in Python:

https://github.com/ConceptJunkie/rpn

My rpn calculator started out comparable to the project described here, once I discovered the mpmath library, the project took on a life of its own and now has over 400 operations covering basic math, number theory, combinatorics, unit conversions (comparable to the GNU units program, or the Frink programming language), algebra and anything else that strikes my fancy.

The algorithm I use combines shunting-yard and postfix (RPN) evaluation, but I guess it wouldn't be too hard to modify the source to just do the RPN part.

If you want to try that, the relevant code is the Evaluate function in `compute/compute.go`.

A Google search for "command line calculator" doesn't turn up much, so I honestly didn't think there were many decent ones out there (aside from dc/bc). Are there any you have in mind?

Incidentally I wrote a simple CLI RPN calc in half an hour recently: https://github.com/alexander-b/clac

I was planning on adding a REPL-mode to it today for fun, and then someone linked me this post, saying "this could have been clac!", hehe.

I use the M-x calc in Emacs for this reason.
I find emacs calc very fitting the RPN tradition (reminiscent of HP pocket calculators), since it provides an algebraic solver; always a pleasurable thing to witness.
Obligatory XKCD: http://xkcd.com/645/