CLIPS-谓词字段约束

一、

?print-mark<-(printmark (name ?name)(no?no&:(numberp ?no)))中)(no?no&:(numberp ?no))表示no谓词字段约束,即:no一定要为数字。

二、操作
CLIPS (Quicksilver Beta 09/24/07)
CLIPS> (deftemplate student
(slot name)
(slot no)
(slot mark))

CLIPS>
(deftemplate printmark
(slot name)
(slot no)
)
CLIPS> (assert (student(name liuhui)(no 1)(mark60))
(student(name liuhui)(no 2)(mark 70)))

<Fact-2>

CLIPS> (defrule print-studentmark
?print-mark<-(printmark (name ?name)(no?no&:(numberp ?no)))
(student (name ?name) (no ?no)(mark ?mark))
=>
(retract ?print-mark)
(printout t "mark:" ?mark crlf)
)

CLIPS> (facts)
f-0(initial-fact)
f-1(student (name liuhui) (no 1) (mark 60))
f-2(student (name liuhui) (no 2) (mark 70))
For a total of 3 facts.

CLIPS> (assert (printmark (name liuhui)(no1)))
<Fact-3>
CLIPS> (run)
mark:60
CLIPS> (assert (printmark (name liuhui)(noerr)))
<Fact-4>
CLIPS> (run)
CLIPS> (facts)
f-0(initial-fact)
f-1(student (name liuhui) (no 1) (mark 60))
f-2(student (name liuhui) (no 2) (mark 70))
f-4(printmark (name liuhui) (no err))
For a total of 4 facts.
CLIPS>

你可能感兴趣的:(F#)