2017-05-24 2 views

Antwort

1
CLIPS> 
(defclass A 
    (is-a USER) 
    (multislot INTS)) 
CLIPS> (make-instance [a] of A (INTS 1 2 3)) 
[a] 
CLIPS> (send [a] print) 
[a] of A 
(INTS 1 2 3) 
CLIPS> (bind ?INSTANCE [a]) 
[a] 
CLIPS> (bind ?existing_total_count (nth$ 2 (send ?INSTANCE get-INTS))) 
2 
CLIPS> (bind ?total_count 3) 
3 
CLIPS> (slot-replace$ ?INSTANCE INTS 2 2 (+ ?total_count ?existing_total_count)) 
(1 5 3) 
CLIPS> (send [a] print) 
[a] of A 
(INTS 1 5 3) 
CLIPS> (bind ?total_count 5) 
5 
CLIPS> (send ?INSTANCE put-INTS (replace$ (send ?INSTANCE get-INTS) 2 2 (+ ?total_count ?existing_total_count))) 
(1 7 3) 
CLIPS> (send [a] print) 
[a] of A 
(INTS 1 7 3) 
CLIPS> 
+0

danke für die Antwort .. Ich bin mir nicht bewusst, es ist eine Slot-ersetzen verfügbar .. durch Verwendung von Slot-ersetzen $ Ich sehe [a] wurde geändert, bedeutet es Bindung wird tatsächlich erhalten eine Referenz von [a] in INSTANCE..wenn wir [a] drucken, zeigte es 1 5 3, und die zweite Möglichkeit, Einträge zu ändern, ist put-INTS mit replace $? – naren

+0

Dokumentationslinks sind hier: http://www.clipsrules.net/?q=Documentation. Der gebundene Wert von? INSTANCE wird sich als Ergebnis der Verwendung von Put-INTS nicht ändern. –