An Introduction to Scheme and its Implementation - Recursive Evaluation Go to the first , previous , next , last section, table of contents .
Evaluation is done recursively.
We write code to evaluate simple expressions, and use recursion to break down complicated expressions into simple parts. First math-eval checks the expression to see if it's something simple that it can evaluate straightforwardly, without recursion. If so, it just returns that value. If the expression is not simple, it's supposed to be an arithmetic expression with an operator and two operands, represented as a three element list. The 4-function arithmetic evaluator is very simple, but it demonstrates several important principles of Scheme programming and programming language implementation.