CLIPS-事实地址

一、

1、?f1<-和?f2<-等表示事实地址,用?事实名<-表示。

2、操作表示把指定某人的城市更换为某地。

二、操作

CLIPS (Quicksilver Beta 09/24/07)
CLIPS> (clear)
CLIPS> (deftemplate person
(slot name)
(slot city))
CLIPS> (deftemplate moved-personinfo-process
(slot name)
(slot city))
CLIPS> (defrule change-personinfo
?f1 <- (moved-personinfo-process (name ?name)(city?city))
?f2 <- (person (name ?name))
=>
(retract ?f1)
(modify ?f2 (city ?city)))
CLIPS> (reset)
CLIPS> (watch rules)
CLIPS> (watch facts)
CLIPS> (deffacts people
(person (name liuxiang)(city changsha))
(person (name huajun)(city shanghai))
)
CLIPS> (reset)
<==f-0(initial-fact)
==>f-0(initial-fact)
==>f-1(person (name liuxiang) (city changsha))
==>f-2(person (name huajun) (city shanghai))
CLIPS> (assert (moved-personinfo-process (nameliuxiang)(city zhanjiang)))
==>f-3(moved-personinfo-process (name liuxiang) (city zhanjiang))
<Fact-3>
CLIPS> (run)
FIRE 1change-personinfo: f-3,f-1
<==f-3(moved-personinfo-process (name liuxiang) (city zhanjiang))
<==f-1(person (name liuxiang) (city changsha))
==>f-4(person (name liuxiang) (city zhanjiang))
CLIPS> (facts)
f-0(initial-fact)
f-2(person (name huajun) (city shanghai))
f-4(person (name liuxiang) (city zhanjiang))
For a total of 3 facts.
CLIPS>

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