Skip to content

Instantly share code, notes, and snippets.

@u8y7541
u8y7541 / rpn.py
Last active November 13, 2016 22:56
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())),