|
|
Examples of expressions and their values |
|
|
| The conditional expression is evaluated in two steps. First the boolean expression (even? x) is evaluated. If x is even, the boolean expression (even? x) evaluates to true and the trivial expression 7 is evaluated. Because x is 3 and therefore odd, the other expression (+ x 5) is evaluated, giving us the final value 8. It is important to realize that an if form does not evaluate all three constituent expressions at the outset. It first evaluates the boolean expression, and based on the outcome, it either evaluates the 'then part' or the 'else part'. Not both! We have much more to say about the order of evaluation of an if form in a later part of this material |
| Regarding the lambda expression, the x in parentheses after lambda is the formal parameter of the function. the expression (+ x 1) is the body. In functions, the body is an expression - not a command. |
| The HTML mirror expressions stem from the LAML libraries. The functions html, body, title, head, and p correspond to the HTML elements of the same names. In the LAML software, the HTML elements are mirrored as functions in Scheme. |