Advertisement
ldevillez

Eval

Nov 18th, 2016
2,520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 0.71 KB | None | 0 0
  1. local Stack Result in
  2.     Stack={NewStack}
  3.     Result={NewStack}
  4.     for I in {Length L}..1;~1 do
  5.         {Push Stack {Nth L I}}
  6.     end
  7.     for while:{Not {IsEmpty Stack}} do
  8.         local Elt in
  9.             Elt={Pop Stack}
  10.             case Elt of
  11.                '+' then {Push Result {Pop Result}+{Pop Result}}
  12.             [] '*' then {Push Result {Pop Result}*{Pop Result}}
  13.             [] '-' then {Push Result ~{Pop Result}+{Pop Result}}
  14.             [] '/' then
  15.                 local X Y in
  16.                     X={Pop Result}
  17.                     Y={Pop Result}
  18.                     {Push Result Y div X}
  19.                 end
  20.             else {Push Result Elt} end
  21.         end
  22.     end
  23.     {Pop Result}
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement