Equality of two multislot variables

442 views
Skip to first unread message

navid

unread,
May 14, 2011, 4:28:43 AM5/14/11
to CLIPSESG
Hello there
I'm newcomer in clips...As you see in the following code, i have
several multislot variables from different deftemplates and i wanna
write a rule which compare equality of them and then assert unequal
fact from first deftemplate into a new deftemplate, i used from this
statement (test (neq $?t1 $?t2)) but it doesn't work, i think it works
only on strings which are the same. Is there any way to do it?
can you help me?
Thanks

(deftemplate ino
(multislot str))

(deftemplate inp
(multislot str))

(deftemplate equal
(multislot str))

(deffacts initial
(ino (st one two three)) *
(ino (st one three four))
(inp (st two one three)) *
(inp (st one four))
...
)

(defrule check-equal
(ino (st $?t1))
(inp (st $?t2))
(test (neq $?t1 $?t2))
=>
(equal(str ?t1)))

CLIPS Support

unread,
May 21, 2011, 8:01:00 PM5/21/11
to CLIPSESG
CLIPS>
(deftemplate ino
(multislot str))
CLIPS>
(deftemplate inp
(multislot str))
CLIPS>
(deftemplate equal
(multislot str))
CLIPS>
(deffacts initial
(ino (str one two three))
(ino (str one three four))
(inp (str two one three))
(inp (str one four)))
CLIPS>
(defrule check-equal
(ino (str $?t1))
(inp (str $?t2))
(test (neq $?t1 $?t2))
=>
(assert (equal (str ?t1))))
CLIPS> (reset)
CLIPS> (run)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (ino (str one two three))
f-2 (ino (str one three four))
f-3 (inp (str two one three))
f-4 (inp (str one four))
f-5 (equal (str one two three))
f-6 (equal (str one three four))
For a total of 7 facts.
CLIPS>
Reply all
Reply to author
Forward
0 new messages