Parsing/RPN calculator algorithm: Difference between revisions

Content added Content deleted
(added Factor back)
Line 1,296: Line 1,296:
=={{header|Factor}}==
=={{header|Factor}}==
Factor <i>is</i> a stack-based evaluator for an expression in reverse Polish notation. In the listener:
Factor <i>is</i> a stack-based evaluator for an expression in reverse Polish notation. In the listener:
<lang factor>
<lang factor>IN: scratchpad 3 4 2 * 1 5 - 2 3 ^ ^ / +
IN: scratchpad 3 4 2 * 1 5 - 2 3 ^ ^ / +


--- Data stack:
--- Data stack:
Line 1,303: Line 1,302:


To show intermediate steps:
To show intermediate steps:
<lang factor>
<lang factor>{ 3 4 2 * 1 5 - 2 3 ^ ^ / + } [ 1quotation ] map
[ dup pprint bl call datastack . ] each</lang>
{ 3 4 2 * 1 5 - 2 3 ^ ^ / + } [ 1quotation ] map
[ dup pprint bl call datastack . ] each
</lang>
{{out}}
{{out}}
<pre>
<pre>