CLIPS-多字段变量

一、$?表示多字段,以下操作为列出某人的小孩名字(一个人可以有多个小孩)

二、操作

CLIPS (Quicksilver Beta 09/24/07)
CLIPS> (deftemplate person
(multislot name)
(multislot children))
CLIPS> (deffacts some-people
(person (name liu hua)
(children liujun liuhun))
(person (name huang hua li)
(children huangwangjun huanghui))
)
CLIPS> (defrule print-children
(print-children $?name)
(person (name $?name)(children $?children))
=>
(printout t $?name "has children " $?children crlf))
)

CLIPS> (list-defrules)
print-children
For a total of 1 defrule.
CLIPS> (reset)
CLIPS> (assert (print-children liu hua))
<Fact-3>
CLIPS> (run)
(liu hua)has children (liujun liuhun)
CLIPS>

你可能感兴趣的:(cli)