I know it can be achieved making two rules, one which is satisfying conditions and the other just reverse of it
but i would like to know is there is easier way to have same functionality
example of having two rules to achieve else part:
(defrule ifpart
(value1 ?first)
(value2 ?second)
(test (> ?first ?second) => (printout t " first is bigger") )
(defrule elsepart
(value1 ?first)
(value2 ?second)
(test (< ?first ?second) => (printout t " second is bigger") )
actually if rule is simple then it is little easy to write two rules, but when it becomes bigger then flooding the rule file is little trouble, so please let me know if i can….
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In general, there's no else condition for a rule. In a simple case such as this, you can move the expression into the then portion of the rule, but in more complex cases you need a second rule:
(defrule ifpart
(value1 ?first)
(value2 ?second)
=>
(if (> ?first ?second)
then (printout t " first is bigger")
else (if (> ?second ?first) then (printout t " second is bigger"))))
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi folks,
I know it can be achieved making two rules, one which is satisfying conditions and the other just reverse of it
but i would like to know is there is easier way to have same functionality
example of having two rules to achieve else part:
(defrule ifpart
(value1 ?first)
(value2 ?second)
(test (> ?first ?second) => (printout t " first is bigger") )
(defrule elsepart
(value1 ?first)
(value2 ?second)
(test (< ?first ?second) => (printout t " second is bigger") )
actually if rule is simple then it is little easy to write two rules, but when it becomes bigger then flooding the rule file is little trouble, so please let me know if i can….
In general, there's no else condition for a rule. In a simple case such as this, you can move the expression into the then portion of the rule, but in more complex cases you need a second rule: