3.3.1 Changed Table Structure

xiaoxiao2021-03-06  22

Use EQ? To compare whether the table structure is shared, (EQ? X Y). EQ? In fact, it is the same as the X, Y pointer. The following figure, Z1 -> ((A b) A b), Z2 -> ((A b) a b), it seems to have no difference.

In fact, (EQ? (CAR Z1) (CDR Z1)) -> # T, (EQ? (CAR Z2) (CDR Z2)) -> # f I (SET-Car! (Car Z1) ' WOW), then z is (wow b) wow b), because the pointer in Z1 will point from the pointer to A, turn to 'WOW. The following is the implementation of cons, but the code on the book will be erroneous, it should be changed to the following look (Define (set! Xv)) (Define (SET-Y! v) (Set! YV)) (COND ((EQ? M 'CAR) Y) ((EQ? M' CDR) Y) ((EQ? M 'Set-Car!) SET-X !) ((Else (Erse (Erse (Erse (Erse (Erse ")))))))) (Define (CAR Z) (Define) (Define) CDR Z) (Z 'CDR)) ((Set-Car! Z New) ((z' set-car!) (DEFINE (SET-CDR! Z NEW) ((Z 'Set-CDR!) NEW))

转载请注明原文地址:https://www.9cbs.com/read-56802.html

New Post(0)