正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology multiply it by itself, and return that value Language elements -abstractions Need to capture ways of doing things-use parameters (lambda(x)( xx)l To process something multiply it by itself 1m003 6 001 SICP Slide 2.1.9 So in fact this particular lambda expression captures the process of"squaring". It says, if you give me a value for x I will return Language elements--abstractions the value of multiplying that value by itself. In a second we will Need to capture ways of doing things-use see how this happens procedures r parameters Notice that lambda expressions must be special forms. The (lambda(x)( x x)h-body normal rules for evaluating a combination do not apply here To process something multiply it by itself Instead, the value returned by evaluating a lambda expression is the actual procedure that it captures. Contained within that procedure will be a set of formal parameters, and a body that Special form-creates a procedure and returns it captures the common pattern of the process, as a function of 410 60153C those formal parameters Slide 2.1.10 Language elements--abstractions Now,where can we use such a procedure? Basically anywhere in our earlier expressions that we could use a built-in Use this anywhere you would use a procedure procedure, which for now means as the first element in a ( lambda(x×)(xx)5) combination For example, here is a compound expression, with two subexpressions. What is the value or meaning associated with it? The value of the first subexpression we just saw was a procedure. The value of the second subexpression is just the number 5. Now we have something similar to our earlier cases 410200 6 001 SICP ions a procedure applied to a value. The only difference is that her we have a procedure we built, rather than a pre-existing one We need to specify how such a procedure is applied to a set of arguments6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 2.1.8 ... multiply it by itself, and return that value. Slide 2.1.9 So in fact this particular lambda expression captures the process of "squaring". It says, if you give me a value for x I will return the value of multiplying that value by itself. In a second we will see how this happens. Notice that lambda expressions must be special forms. The normal rules for evaluating a combination do not apply here. Instead, the value returned by evaluating a lambda expression is the actual procedure that it captures. Contained within that procedure will be a set of formal parameters, and a body that captures the common pattern of the process, as a function of those formal parameters. Slide 2.1.10 Now, where can we use such a procedure? Basically anywhere in our earlier expressions that we could use a built-in procedure, which for now means as the first element in a combination. For example, here is a compound expression, with two subexpressions. What is the value or meaning associated with it? The value of the first subexpression we just saw was a procedure. The value of the second subexpression is just the number 5. Now we have something similar to our earlier cases, a procedure applied to a value. The only difference is that here we have a procedure we built, rather than a pre-existing one. We need to specify how such a procedure is applied to a set of arguments
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有