2016-09-19 2 views
0

I가 다음과 같은 사실 :루프 클립에 사실을 만들 수

(deffacts Cars 
    (color red) 
    (color green) 
    (color yellow) 
    (doors three) 
    (doors five) 
) 

인가는 5 개의 빨간 (자동차 세 빨간색), (자동차와 같은 새로운 사실을 만들 사실을 통해 루프 defrule을 만들 수 있습니다), (자동차 녹색 3), (...), 가능한 모든 색상 및 문구 조합?

감사

답변

3
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> 
+0

덕분에 회색이 환상적이다! – Selrac