Skip to content

Instantly share code, notes, and snippets.

View kahagon's full-sized avatar

Kenichi Ahagon kahagon

View GitHub Profile
@sma
sma / upn.py
Created March 10, 2010 14:28
upn calculator
from operator import add, sub, mul, truediv as div
operations = {"+": add, "-": sub, "*": mul, "/": div}
stack = []
def upn(line):
for token in line.split():
if token in operations:
b, a = stack.pop(), stack.pop()