RosettaCodeData/Task/Parsing-RPN-calculator-algorithm/11l/parsing-rpn-calculator-algorithm.11l

17 lines
394 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
[Float] a
[String = ((Float, Float) -> Float)] b
b[+] = (x, y) -> y + x
b[-] = (x, y) -> y - x
b[*] = (x, y) -> y * x
b[/] = (x, y) -> y / x
b[^] = (x, y) -> y ^ x
L(c) 3 4 2 * 1 5 - 2 3 ^ ^ / +.split( )
I c C b
V first = a.pop()
V second = a.pop()
a.append(b[c](first, second))
E
a.append(Float(c))
print(c a)