正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology procedures associated with the manipulation of those data structures. We will see that data abstractions mirror many of the properties of procedural abstractions, and we will thus generalize the ideas of compound data into data abstractions, to complement our procedural abstractions Com pound data Slide 5.2.2 So far almost everything we've seen in Scheme has revolved around numbers and computations associated with numbers This has been partly deliberate on our part, because we wanted to focus on the ideas of procedural abstraction, without gettin bogged down in other details. There are, however, clearly problems in which it is easier to think in terms of other elements than just numbers, and in which those elements have pieces that need to be glued together and pulled apart, while preserving the concept of the Slide 5.2.3 Com pound data So our goal is to create a method for taking primitive data elements, gluing them together, and then treating the result as if that can be treated as a simple data element into a unit it were itself a primitive element. Of course, we will need a way Need ways of getting the pieces back out of" de-gluing" the units, to get back the constituent parts What do we mean when we say we want to treat the result of gluing elements together as a primitive data element? Basically we want the same properties we had with numbers: we can apply procedures to them, we can use procedures to generate new versions of them, and we can create expressions that include them as simpler elements 6001 SICP Com pound data Slide 5.2. 4 into a unit The most important point when we"glue"things together is to have a contract associated with that process. This means that we don't really care that much about the details of how we glue .Need a contract between the "glue" and the " unglue things together, so long as we have a means of getting back out the pieces when needed. This means that the"glue"and the unglue"work hand in hand, guaranteeing that however, the compound unit is created we can always get back the parts we6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. procedures associated with the manipulation of those data structures. We will see that data abstractions mirror many of the properties of procedural abstractions, and we will thus generalize the ideas of compound data into data abstractions, to complement our procedural abstractions. Slide 5.2.2 So far almost everything we've seen in Scheme has revolved around numbers and computations associated with numbers. This has been partly deliberate on our part, because we wanted to focus on the ideas of procedural abstraction, without getting bogged down in other details. There are, however, clearly problems in which it is easier to think in terms of other elements than just numbers, and in which those elements have pieces that need to be glued together and pulled apart, while preserving the concept of the larger unit. Slide 5.2.3 So our goal is to create a method for taking primitive data elements, gluing them together, and then treating the result as if it were itself a primitive element. Of course, we will need a way of "de-gluing" the units, to get back the constituent parts. What do we mean when we say we want to treat the result of gluing elements together as a primitive data element? Basically we want the same properties we had with numbers: we can apply procedures to them, we can use procedures to generate new versions of them, and we can create expressions that include them as simpler elements. Slide 5.2.4 The most important point when we "glue" things together is to have a contract associated with that process. This means that we don't really care that much about the details of how we glue things together, so long as we have a means of getting back out the pieces when needed. This means that the "glue" and the "unglue" work hand in hand, guaranteeing that however, the compound unit is created, we can always get back the parts we started with
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有