6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 2.1.15 Thus, lambda gives us the ability to capture procedure abstractions-- patterns of computation in a single procedure Language elements --abstractions But we don't want to have to write out lambda expressions everywhere we need to use this procedure Use this an you would use a procedure Instead, we can combine this procedural abstraction with our ((lambda(x)(xx))5) naming abstraction--that is, we can use a define expression to (55) give a name to a procedure. In this case, the name square will be paired with the value of the lambda expression, or quite literally with the actual procedure created by evaluating that (define lambda(x)(xx))) (square lambda Then we can use the name square wherever we want the 10003 6001 sICP procedure, since its value is the actual procedure. If you follow the rules of evaluation for the last expression, you will see that we get a procedure applied to a number, and the substitution of the argument into the body of the procedure reduces to a simpler expression, just as we saw earlier 6.001 Notes: Section 2.2 Slide 2.2.1 Lambda: making new procedures The second kind of special form we saw was a lambda expression, and lambda we said was our way of capturing rocesses inside procedures. Lambda is Greek for "procedure (lambda (x)(*x*)) maker", and is our way of saying" Take this pattern, and capture in a way that will let me reuse it multiple times". In our two world view, if we type this expression into the computer and ask it to be evaluated, the computer uses the key word lambda to determine that this is a particular special form. It will then use the rule designed for this type of expression 1 001 SICP Lambda: making new procedures Slide 2.2.2 It is important to stress that the actual value created inside the machine is some representation for the procedure itself. This (lambda (at) ( c x )) representation includes information about the parameters of the procedure, and the body of the procedure, that is, what pattern of computation is being captured, and what are the variables to be replaced in that pattern when we want to use this procedure But it is the actual procedure representation that is associated a the value of the expression6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 2.1.15 Thus, lambda gives us the ability to capture procedure abstractions -- patterns of computation in a single procedure. But we don't want to have to write out lambda expressions everywhere we need to use this procedure. Instead, we can combine this procedural abstraction with our naming abstraction -- that is, we can use a define expression to give a name to a procedure. In this case, the name square will be paired with the value of the lambda expression, or quite literally with the actual procedure created by evaluating that lambda. Then we can use the name square wherever we want the procedure, since its value is the actual procedure. If you follow the rules of evaluation for the last expression, you will see that we get a procedure applied to a number, and the substitution of the argument into the body of the procedure reduces to a simpler expression, just as we saw earlier. 6.001 Notes: Section 2.2 Slide 2.2.1 The second kind of special form we saw was a lambda expression, and lambda we said was our way of capturing processes inside procedures. Lambda is Greek for "procedure maker", and is our way of saying "Take this pattern, and capture in a way that will let me reuse it multiple times". In our two world view, if we type this expression into the computer and ask it to be evaluated, the computer uses the key word lambda to determine that this is a particular special form. It will then use the rule designed for this type of expression. Slide 2.2.2 It is important to stress that the actual value created inside the machine is some representation for the procedure itself. This representation includes information about the parameters of the procedure, and the body of the procedure, that is, what pattern of computation is being captured, and what are the variables to be replaced in that pattern when we want to use this procedure. But it is the actual procedure representation that is associated as the value of the expression