I am fairly new to CLIPS , been trying to implement a program , based on a lecture , that adds the values of 2 slots , of two facts respectively. I begin with defining the templates of o1
, o2
(the two facts that we add) and o3
(where we store the result) . Each of the first two facts , o1
and o2
, have 2 slots , s1
and s2
. The slots of o3
are r1
and r2
. Then I proceed to initialize the slots o1
and o2
, using deffacts . Then , ending , using defrule , I set variables to the slots of o1
and o2
and using assert to generate the o3
fact , which slots r1
will have the sum of values of the first slot of the facts o1
and o2
, and r2
will the sum of the second . I'm using ubuntu , loading the clp clips file with clips -f try.clp
command , and then executing (run)
and at last , (facts)
, but can't see the new facts , or either of the pre-existing ones . Can someone guide me with this ? I'm posting my code and screenshot of running the program.
Here is my code :
(deftemplate o1
(slot s1)
(slot s2))
(deftemplate o2
(slot s1)
(slot s2))
(deftemplate o3
(slot r1)
(slot r2))
; Facts
(deffacts F
(o1 (s1 3)(s2 5))
(o2 (s1 7)(s2 9)))
; Rules
(defrule R
(o1 (s1 ?x1)(s2 ?y1))
(o2 (s1 ?x2)(s2 ?y2))
=>
(assert (o3(r1 (+ ?x1 ?x2))(r2 (+ ?y1 ?y2))))
)
and screenshot with running the program :