Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
RPN = function(inputText)
|
||||
tokens = inputText.split
|
||||
stack = []
|
||||
while tokens
|
||||
tok = tokens.pull
|
||||
if "+-*/^".indexOf(tok) != null then
|
||||
b = stack.pop
|
||||
a = stack.pop
|
||||
if tok == "+" then stack.push a + b
|
||||
if tok == "-" then stack.push a - b
|
||||
if tok == "*" then stack.push a * b
|
||||
if tok == "/" then stack.push a / b
|
||||
if tok == "^" then stack.push a ^ b
|
||||
else
|
||||
stack.push val(tok)
|
||||
end if
|
||||
print tok + " --> " + stack
|
||||
end while
|
||||
return stack[0]
|
||||
end function
|
||||
|
||||
print RPN("3 4 2 * 1 5 - 2 3 ^ ^ / +")
|
||||
Loading…
Add table
Add a link
Reference in a new issue