| |
a disembodied property list:只能使用 -> 操作符,只能用 ' ,不能用list
Example:
myDPL= '(nil rePart 2 imPart 10)
foreach(Part reverse(myDPL->?)
println(list("Part:" Part, "Value:" get(myDPL Part) ))
)
Output:
("Part:" rePart "Value:" 2)
("Part:" imPart "Value:" 10)
(rePart imPart)
Another approach could be like;
hand1='(nil name "Albert" card1 '(nil suit "clubs" value "ace") card2 '(nil suit "diamond" value "king"))
hand2=copy(hand1),copy这个非实体属性列表,然后给hand2赋值之后,依然相互链接相互关联。比如:
hand2->name="George"
hand2->card1->suit="hearts"
hand2->card1->value="jack"
hand2->card2->suit="spades"
hand2->card2->value="9"
hand1的值随着hand2的改变而改变!
用下面这个函数hand2=CCSdeepCopy(hand1),即可解决!
procedure(CCSdeepCopy(l1)
foreach(mapcar elem l1
if(listp(elem) then
CCSdeepCopy(elem)
else
elem
)
)
)