Diversion

A little Python snippet, good for a diversion. I couldn’t fit it into a tweet though: s=[];op=dict((o,eval(‘lambda a,b:b%sa’%o)) for o in ‘+-*/%’) while not any(s.append(op[w](s.pop(),s.pop())if w in op else float(w)) for w in raw_input().split()): print ‘=’,s[-1] Just a simple 4-function RPN calculator, accepting input from console: 1 = 1.0 2 2 + = 4.0 1 …