Unformatted text preview: The substitute procedure is essentially the substitute2 that you wrote in last week’s homework, except that it has to be a little more complicated to avoid substituting for quoted symbols and for the formal parameters of a lambda inside the body. What’s left out? Primitives, special forms, and a lot of details. The Scheme1 interpreter has only three special forms: quote , if , and lambda . In particular, it doesn’t have define , so there are no global variables, and we can’t give procedures global names. If we need a name for a procedure, we have to use it as an argument to another procedure. In particular, if we want to write recursive procedures we have to use a trick that was an extraforexperts in week 2: Scheme1: ((lambda (n) ((lambda (f) (f f n)) ; the "Y combinator" (lambda (fact n) (if (= n 0) 1 (* n (fact fact ( n 1))) )) )) 5) 120 307...
View
Full Document
 Spring '10
 Harvey,B
 Recursion, Control flow

Click to edit the document details