Skip to content

Instantly share code, notes, and snippets.

View rpn.py
stackAdd, stackSub, stackDiv, stackMult, stackExp, stackMod, stackFac, stackIntDiv, inner, evalRPN = lambda stack: stack.append(stack.pop() + stack.pop()), lambda stack: stack.append((stack.pop() - stack.pop()) * -1), \
lambda stack: stack.append(1 / (stack.pop() / stack.pop())), lambda stack: stack.append(stack.pop() * stack.pop()), \
lambda stack: stack.append(stack[-2] ** (stack.pop(), stack.pop())[0]), lambda stack: \
stack.append(stack[-2] % (stack.pop(), stack.pop())[0]), \
lambda stack: stack.append(eval(''.join([str(i) + '*' for i in range(1, int(stack.pop()) + 1)]) + '1')), \
lambda stack: stack.append((lambda a, b: b // a)(stack.pop(), stack.pop())),