Jump to content

Parsing/RPN to infix conversion: Difference between revisions

m
Line 2,106:
for tok in rpn
if all(isnumber, tok)
push!(infix, parse(Int, tok))
else
last = pop!(infix)
Line 2,122:
{{output}}
<pre>
Current step: Any["3", :("4" * "2")]
Current step: Any["3", :("4" * "2"), :("1" - "5")]
Current step: Any["3", :("4" * "2"), :("1" - "5"), :("2" ^ "3")]
Current step: Any["3", :("4" * "2"), :(("1" - "5") ^ ("2" ^ "3"))]
Current step: Any["3", :(("4" * "2") / ("1" - "5") ^ ("2" ^ "3"))]
Current step: Any[:("3" + ("4" * "2") / ("1" - "5") ^ ("2" ^ "3"))]
The final infix result: Any[:("3" + ("4" * "2") / ("1" - "5") ^ ("2" ^ "3"))]
 
Current step: Any[:("1" + "2")]
Current step: Any[:("1" + "2"), :("3" + "4")]
Current step: Any[:(("1" + "2") ^ ("3" + "4"))]
Current step: Any[:(("1" + "2") ^ ("3" + "4")), :("5" + "6")]
Current step: Any[:((("1" + "2") ^ ("3" + "4")) ^ ("5" + "6"))]
The final infix result: Any[:((("1" + "2") ^ ("3" + "4")) ^ ("5" + "6"))]
</pre>
 
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.