6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 8.2.4 Your turn: what does evaluating these print out? So let's take a quick break to see if you are getting this idea. Here are a set of expressions. What gets printed out as a result of evaluating each of these? When you think you have the answers go to the next slide (+x3) (list (quote +)x '3 (1st'+x3 (list 3 Slide 8.2.5 So here are the solutions. First, notice that we have defined x to Your turn what does evaluating these print out? have the value 20, creating a pairing of that value with that name Evaluating the first expression just gives us a normal (define x 20) combination, resulting in the addition of 3 to the value of x, or 23.(+x 3) The next expression, with the single quote, says to just return a list whose printed representation is equivalent to this, i.e. the list =>(+x3) of'+, 'x and3, or the list of the symbol + the symbol x and the (1st( quote+)x3)=>(+203) number 3. Thus what is printed out is the same expression as what was quoted >(+203) The next expression draws a distinction with this example. It says (list+* 3y =>(procedure #...]20 3) to create a list of a quoted +, the value of x, and the quoted value 4 of 3. Thus we get a list of the symbol +(because we quoted it), the number 20. since we asked for the value of x. and the number 3 The next expression returns the same value, since quoting a number just returns the number Finally, what happens if we just ask for the list of+, x and 3? Well, we get a list of the values of each of these expressions, as shown Thus, these examples show the variations in the use of quotation within list structure, determining when the values of expressions are returned and when the names are simply returned 6.001 Notes: Section 8.3 Slide 8.3.1 mbolic differentiation Let's take the idea of symbols, and combine it with some of the other lessons we' ve seen so far, to see how symbols add to the expressive power of our language. To do this, we'll look at the Algebraic expression Representation example of symbolic derivatives, in particular, creating a system to compute symbolic derivatives. By that, I mean returning symbolic expressions, much as you do in calculus Thus, I want a system that takes some representation for the algebraic expression x 3 and some representation for the variable x, and returns the derivative of this expression with respect to that variable6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 8.2.4 So let's take a quick break to see if you are getting this idea. Here are a set of expressions. What gets printed out as a result of evaluating each of these? When you think you have the answers, go to the next slide. Slide 8.2.5 So here are the solutions. First, notice that we have defined x to have the value 20, creating a pairing of that value with that name. Evaluating the first expression just gives us a normal combination, resulting in the addition of 3 to the value of x, or 23. The next expression, with the single quote, says to just return a list whose printed representation is equivalent to this, i.e. the list of '+, 'x and '3, or the list of the symbol +, the symbol x and the number 3. Thus what is printed out is the same expression as what was quoted. The next expression draws a distinction with this example. It says to create a list of a quoted +, the value of x, and the quoted value of 3. Thus we get a list of the symbol + (because we quoted it), the number 20, since we asked for the value of x, and the number 3. The next expression returns the same value, since quoting a number just returns the number. Finally, what happens if we just ask for the list of +, x and 3? Well, we get a list of the values of each of these expressions, as shown. Thus, these examples show the variations in the use of quotation within list structure, determining when the values of expressions are returned and when the names are simply returned. 6.001 Notes: Section 8.3 Slide 8.3.1 Let's take the idea of symbols, and combine it with some of the other lessons we've seen so far, to see how symbols add to the expressive power of our language. To do this, we'll look at the example of symbolic derivatives, in particular, creating a system to compute symbolic derivatives. By that, I mean returning symbolic expressions, much as you do in calculus. Thus, I want a system that takes some representation for the algebraic expression x + 3 and some representation for the variable x, and returns the derivative of this expression with respect to that variable