CLIPS-字段约束

一、

&表示对变量的与约束

|表示或

~表示非

以下操作查出与两个人,第一个人有绿眼睛或蓝眼睛,头发不是黑色,第二人与第一人名字不一样,眼睛不一样,但头发一样或为红色

二、

CLIPS (Quicksilver Beta 09/24/07)
CLIPS> (deftemplate person
(slot name)
(slot eye)
(slot hair))
CLIPS> (assert (person (name liuhuihui)(eyeblack)(hair red))
(person (name huangjun)(eye black)(hair yellow))
(person (name zhangjun)(eye black)(hair green))
(person (name liucan)(eye green)(hair yellow)))
<Fact-4>
CLIPS> (defrule persons-match
(person (name ?name1) (eye?eye1&blue|green) (hair?hair1&~black))
(person (name?name2&~?name1) (eye ?eye2&~eye1)(hair ?hair2&red|?hair1))
=>
(printout t ?name1 " has "?eye1 " eyes and " ?hair1 " hair" crlf)
(printout t ?name2 " has "?eye2 " eyes and " ?hair2 " hair" crlf))
CLIPS> (run)
liucan has green eyes and yellow hair
huangjun has black eyes and yellow hair
liucan has green eyes and yellow hair
liuhuihui has black eyes and red hair
CLIPS>

你可能感兴趣的:(cli)