# RPN calculator

## Recommended Posts

A simple RPN calculator that works like the built-in calculator.  Requires spaces as delimiters between elements in the expression.  Built using deanishe's Alfred python library.

e.g.

19 2.14 + 4.5 2 4.3 / - *

produces an Alfred result:

85.2974418605

Action this item to copy this number to the clipboard

There is a single keyword:

rpn

Edited by dfay
• 4 years later...

Does this workflow still work on Alfred3?

Link is broken. Would love to get a copy!

Thanks!

Haha it only took four years for someone to take an interest in this   I've updated the link -- hope you find it useful.

• 2 years later...

I think it needs another update. I get this warning.

6 hours ago, JimmyTheSaint said:

I think it needs another update. I get this warning.

And why don't you follow the instructions to fix the workflow?

No worries I’ll sort it out and post updated version.

@done(2020-07-26)

Edited by dfay

Seems this workflow need some love 😀

• 1 month later...

@dfay Thank you, thank you! I am in your debt. I literally upgraded Alfred just for this.

When I'm on Slack and need to complete a sentence like "we frobnicated 6,122,849 doodads between 8:28 and 12:49, a rate of one million every..."  – which seems to be a lot of my life the past few weeks – there is nothing so useful as a good RPN calculator, and none so close to hand and fast to use as yours. Thank you.

• 8 months later...

@dfay, thanks for this workflow. FYI workflow needs "0" in front of decimal for it to work - for example "RPN 100 .1 *" would end up with wrong result, it needs "RPN 100 0.1 *". Is it by design or potential bug?

I'd like to say it's by design but it's actually an artifact of the crazy regular expression in rpn.py line 42:

ops = map(lambda y: y.replace(' ',''), re.split('\s|(?<!\d)[,.]|[,.](?!\d)',query))

Ok. Just have to be careful when entering decimal numbers, habit of keying without leading "0". Only discovered this "issue" when result came out too big. It interprets ".10" as "10" 😲