循环规则以在 CLIPS 中创建事实
Loop in rule to create facts in CLIPS
我有以下事实:
(deffacts Cars
(color red)
(color green)
(color yellow)
(doors three)
(doors five)
)
是否可以创建 defrule 来循环事实以创建新事实,例如(汽车红色三),(汽车红色五),(汽车绿色三),(...),用于所有可能的组合颜色和门?
谢谢
CLIPS>
(deffacts Cars
(color red)
(color green)
(color yellow)
(doors three)
(doors five))
CLIPS>
(defrule combinations
(color ?color)
(doors ?doors)
=>
(assert (car ?color ?doors)))
CLIPS> (reset)
CLIPS> (run)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (color red)
f-2 (color green)
f-3 (color yellow)
f-4 (doors three)
f-5 (doors five)
f-6 (car red five)
f-7 (car green five)
f-8 (car yellow five)
f-9 (car red three)
f-10 (car green three)
f-11 (car yellow three)
For a total of 12 facts.
CLIPS>
我有以下事实:
(deffacts Cars
(color red)
(color green)
(color yellow)
(doors three)
(doors five)
)
是否可以创建 defrule 来循环事实以创建新事实,例如(汽车红色三),(汽车红色五),(汽车绿色三),(...),用于所有可能的组合颜色和门?
谢谢
CLIPS>
(deffacts Cars
(color red)
(color green)
(color yellow)
(doors three)
(doors five))
CLIPS>
(defrule combinations
(color ?color)
(doors ?doors)
=>
(assert (car ?color ?doors)))
CLIPS> (reset)
CLIPS> (run)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (color red)
f-2 (color green)
f-3 (color yellow)
f-4 (doors three)
f-5 (doors five)
f-6 (car red five)
f-7 (car green five)
f-8 (car yellow five)
f-9 (car red three)
f-10 (car green three)
f-11 (car yellow three)
For a total of 12 facts.
CLIPS>