Arithmetic evaluation: Difference between revisions

Formed bullet list of task requirements.
(→‎Go: Added)
(Formed bullet list of task requirements.)
Line 1:
{{task}}[[Category:Recursion]]
Create a program which parses and evaluates arithmetic expressions.
Create a program which parses and evaluates arithmetic expressions. Requirements: an [[wp:Abstract_syntax_tree|abstract-syntax tree]] (AST) for the expression must be created from parsing the input. The AST must be used in evaluation, also, so the input may not be directly evaluated (e.g. by calling eval or a similar language feature.) The expression will be a string or list of symbols like "(1+3)*7". The four symbols + - * / must be supported as [[wp:Binary_relation|binary relations]] with conventional precedence rules. Precedence-control parentheses must also be supported.
 
'''Requirements:'''
For those who don't remember, mathematical precedence is as follows:
* An [[wp:Abstract_syntax_tree|abstract-syntax tree]] (AST) for the expression must be created from parsing the input.
*Parentheses
* The AST must be used in evaluation, also, so the input may not be directly evaluated (e.g. by calling eval or a similar language feature.)
*Multiplication/Division (left to right)
* The expression will be a string or list of symbols like "(1+3)*7".
*Addition/Subtraction (left to right)
* The four symbols + - * / must be supported as [[wp:Binary_relation|binary relations]] with conventional precedence rules.
* Precedence-control parentheses must also be supported.
 
Note: For those who don't remember, mathematical precedence is as follows:
* Parentheses
* Multiplication/Division (left to right)
* Addition/Subtraction (left to right)
 
 
Anonymous user