Unformatted text preview: The way calc-eval handles function calls is the only part of the calculator that is not the same as the corresponding feature of real Scheme. That’s because in calculator language, numbers are the only data type, and so in particular procedures aren’t data. In a real Scheme procedure call expression, the first subexpression, the one whose value provides the procedure itself, has to be evaluated just as much as the argument subexpressions. Often the first subexpression is just a variable name, such as + or cdr , but the expression could be ((lambda (x) (+ x 5)) (* 2 3)) in which case the first subexpression is a special form, a lambda expression. But in calculator language, the first sub-“expression” is always the name of the function, and there are only four possibilities: + ,- , * , and / . I put “expression” in quotes because these symbols are not expressions in calculator language. So the expression in calc-eval that handles procedure calls is (calc-apply (car exp) (map calc-eval (cdr exp)))...
View Full Document
This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at Berkeley.
- Spring '10