Arithmetic evaluation: Difference between revisions
Content added Content deleted
(clarification) |
m (Fixed typos and added precedence list.) |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
A program which parsers and evaluates arithmetic expressions. Requirements: an AST for the expression must be created from parsing the input, the AST must be used in evaluation also, so no calling eval or similar if the language has such a thing. |
A program which parsers and evaluates arithmetic expressions. Requirements: an AST for the expression must be created from parsing the input, the AST must be used in evaluation also, so no calling eval or similar if the language has such a thing. The expression will be a string or list of symbols like "(1+3)*7". + - * / as binary operators must be supported including precedence levels, as well as parentheses. |
||
The expression will be a string of list of symbols like "(1+3)*7". |
|||
For those who don't remember, mathematical precedence is as follows: |
|||
+ - * / as binary operators must be supported including precedence levels, as well as paranthesis. |
|||
Parentheses |
|||
Exponents (not in this program) |
|||
Multiplication/Division (left to right) |
|||
Addition/Subtraction (left to right) |
|||
=={{header|Prolog}}== |
=={{header|Prolog}}== |