无法更新CLIPS中的对象,导致剪辑

时间:2017-05-24 12:28:42

标签: clips

 (bind ?existing_total_count (nth$ 2 (send ?INSTANCE ?get-INTS)))
 (send (nth$ 2 (send ?INSTANCE put-INTS)) (+ ?total_count ?existing_total_count))

第一行编译精细,但第二行抛出错误 函数将期望参数#2发送为类型符号

我无法找出问题所在。我正在尝试更新插槽INTS中的第二个条目。

1 个答案:

答案 0 :(得分: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>