6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 2.2.3 And what gets returned? Basically some representation like Lambda: making new procedures this, that identifies that this is a procedure created by evaluating printed representation of value a lambda, and an indication of where it lives inside the machine (lambda (ax)(* xx) 排[ compound-procedure (i.e. how to get at the parameters and body of the procedure). It is important to stress that evaluating a lambda creates an actual procedure object inside the execution world, and that value is actually returned as the value of the expression argument 6001 sICP Interaction of define and lambda Slide 2.2.4 (lambda (x)(** x)) Now let's look at the interaction between creating procedures == #[compound-procedure 91 and giving them names. First of all, I can create a lambda expression, and the value returned by that evaluation is the procedure itself. Note that the procedure is not executed or run here is no numeric value returned here as a square, rather the procedure itself is returned as the val 6001 SICP Slide 2.2.5 Interaction of define and lambda If I actually want to use that procedure I need to refer to it, and the easiest way to do this is to give it a name. So I can define square to be the value returned by that lambda expression a> undef which we just saw is a procedure. This then creates a pairing of the name square with the procedure that captures the pattern of multiplying a value by itself. 60015e Interaction of define and lambda Slide 2.2.6 1.(1 ambda《x)(*xx)) laving done that, I can now write any expression that uses the ==>#compound-procedure 91 name square anyplace that the associated lambda expression 2. (define square (lambda (*)(* xx))) would have been legitimate Note that the evaluation rules nicely cover this This expression 3.(square 4) just get the value sul expressions. Square is a name, so we look up its value, getting back the procedure. This can then be applied to the value of the next sub-expression, using the standard rules for procedure application, namely substitute 4 for x everywhere in the body of the procedure, then evaluate that new expression using the same6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 2.2.3 And what gets returned? Basically some representation like this, that identifies that this is a procedure created by evaluating a lambda, and an indication of where it lives inside the machine (i.e. how to get at the parameters and body of the procedure). It is important to stress that evaluating a lambda creates an actual procedure object inside the execution world, and that value is actually returned as the value of the expression. Slide 2.2.4 Now let's look at the interaction between creating procedures and giving them names. First of all, I can create a lambda expression, and the value returned by that evaluation is the procedure itself. Note that the procedure is not executed or run: there is no numeric value returned here as a square, rather the procedure itself is returned as the value. Slide 2.2.5 If I actually want to use that procedure I need to refer to it, and the easiest way to do this is to give it a name. So I can define square to be the value returned by that lambda expression, which we just saw is a procedure. This then creates a pairing of the name square with the procedure that captures the pattern of multiplying a value by itself. Slide 2.2.6 Having done that, I can now write any expression that uses the name square anyplace that the associated lambda expression would have been legitimate. Note that the evaluation rules nicely cover this. This expression is a standard combination, so we just get the values of the subexpressions. Square is a name, so we look up its value, getting back the procedure. This can then be applied to the value of the next sub-expression, using the standard rules for procedure application, namely substitute 4 for x everywhere in the body of the procedure, then evaluate that new expression using the same rules