正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology preserving the association between a name for a table and the actual representation Slide 10.3.2 Table1 example So let's see how this works first. we will create a table with n (define ttl (make-table1)) ttl by using our constructor Slide 10.3.3 Here is what that looks like. The name ttl points to a list whoseTable1 example car is the symbol tablel(our tag)and whose cdr is just the empty list (i.e. there is nothing in our a-list yet) tablel Slide 10.3.4 Table1 example Now, let's put a new binding of a key and a value into our table, for (define ttl (make-table1)) example, the binding of y and 20 (tablel-put! ttl 'y 20) table Slide 10.3.5 What happens when we use this operation to insert something? Table a list of two elements)and finally"conses"that onto the front of (tablel-put! tt1 702) Remember that table-put! uses add -assoc which extracts the a-list from the tagged representation, (in this case an empty list), and then creates a binding of the arguments (remember that is the a-list. Since this is the empty list, it creates a top level list of one element. as shown tablel 口→6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. preserving the association between a name for a table and the actual representation. Slide 10.3.2 So let's see how this works. First, we will create a table with name tt1 by using our constructor. Slide 10.3.3 Here is what that looks like. The name tt1 points to a list whose car is the symbol table1 (our tag) and whose cdr is just the empty list (i.e. there is nothing in our a-list yet). Slide 10.3.4 Now, let's put a new binding of a key and a value into our table, for example, the binding of y and 20. Slide 10.3.5 What happens when we use this operation to insert something? Remember that table-put! uses add-assoc, which extracts the a-list from the tagged representation, (in this case an empty list), and then creates a binding of the arguments (remember that is a list of two elements) and finally "conses" that onto the front of the a-list. Since this is the empty list, it creates a top level list of one element, as shown
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有