Actually, as of the 5.0a6 release, you can now use 'or' on the LHS of
your rules.  See the latest version of the documentation where it says 

"Ampersands (&) represent logical "and", while pipes (|) represent
logical "or." & has a higher precedence than |, so that the following 

    (foo ?X&:(oddp ?X)&:(< ?X 100)|0)

matches a foo fact with a single field containing either an odd number
less than 100, or 0." 

 If you use this rule 

(defrule a-rule
 (foo ?X&:(oddp ?X)&:(< ?X 100)|0) 
=> (printout t "or works now" crlf))

it works as it says.


Hope that helps,

Benjamin Good
True Image Inc.




Message UK wrote:
> 
> Thanks for your help Lewis. Seems a shame not to be able to do an OR inside
> one rule though. Would save space!
> 
> Debbie Lampon
> 
> >
> >You are correct, the patterns in the LHS of a rule are treated as being
> >ANDed together. To create an OR condition, you could use two or more
> >separate rules. Instead of:
> >
> >Jess> (defrule cantDoThis (test (or (this ?) (that ?))) => (assert
> >(thisandThat)))
> >Rete Exception in routine ReteCompiler::eval.
> >   Message: Unbound variable found in funcall: _blank_2  at line 1:  (
> >defrule cnatDoThis ( test ( or ( this ?_blank_2 ) ( that ?_blank_3 ) ) ) =
> > >
> >( assert ( tat ) ) ) .
> >         at java.lang.Throwable.fillInStackTrace(Native Method)
> >         at java.lang.Throwable.fillInStackTrace(Compiled Code)
> >         at java.lang.Throwable.<init>(Compiled Code)
> >         ....
> >Jess> (assert (this Z))
> ><Fact-0>
> >Jess> (assert (that V))
> ><Fact-1>
> >Jess> (facts)
> >f-0   (this Z)
> >f-1   (that V)
> >For a total of 2 facts.
> >TRUE
> >Jess> (defrule thisRule (this ?) => (assert (thisandThat)))
> >TRUE
> >Jess> (defrule thatRule (that ?) => (assert (thisandThat)))
> >TRUE
> >Jess> (run)
> >TRUE
> >Jess> (facts)
> >f-0   (this Z)
> >f-1   (that V)
> >f-2   (thisandThat)
> >For a total of 3 facts.
> >TRUE
> >Jess>
> >Opinions are strictly those of the author and
> >do not necessarily reflect those of GRCI.
> >____________________________________________
> >Lewis Hart                   GRC International
> >703-506-5938              1900 Gallows Rd
> >[EMAIL PROTECTED]            Vienna, VA 22182
> >
> 
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list (use your own address!) List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to