The "head" or first field of a fact must be known when a rule is
compiled; it can't be the result of a function call.

I will explain how to do what you're trying to do, without asking why
you're trying to do it. It's very unorthodox, and I can't think of a
case where you'd actually want to do things this way. But the
following ought to work:

 (defrule n01
         ?a <- (solution (bottle wine) (position a))
         ?b <- (solution (bottle cola) (position b))
         (test (and (eq ?a ?*a*) (eq ?b ?*b*)))
         => 
         (bind ?*status* -1))


Now, given that: why do you need to associate the global ?*a* with the
wine bottle in the first place? I.e., why isn't the following exactly
equivalent? 


 (defrule n02
         (solution (bottle wine) (position a))
         (solution (bottle cola) (position b))
         => 
         (bind ?*status* -1))

n01 is testing many things simultaneously: It's testing the condition
you're interested in, yes, but it's also testing that the wine bottle
is in global ?*a* and the cola bottle in global ?*b*. Why should the
rule care about these last two conditions?


I think Mark Lilly wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> hi All,
> we had a brain teaser at work and i'm using it to teach myself jess.
> 
> I need to be able to compare two instances of facts from the same
> DefTemplate.
> 
> I tried:
> 
> (deftemplate solution
>         (slot position)
>         (slot bottle)
> )  
> 
> (bind ?*a* (assert (solution       
>                 (position a)
>                 (bottle wine)))
> )
>             
> (bind ?*b* (assert (solution       
>                 (position b)
>                 (bottle cola)))
> )
>                  
> (defrule n01
>         ((call ?*a* getName) (bottle wine))
>         ((call ?*a* getName) (position a))
>         ((call ?*b* getName) (bottle cola))
>         ((call ?*b* getName) (position b))
> =>
>         (bind ?*status* -1)
> ) 
> 
> I want to test for, 
> "if the wine bottle is in position a, then the cola bottle cannot be in
> position b"
> 
> The above two asserted facts would cause the rule to fire, setting status to
> -1, alerting me to the mismatch.
> 
> But, the above rule excepts.  The (call ?*a*) is not adequate for retrieving
> the particular instance of the rule i am looking for.  Substituting
> 'solution' for 'call ?*a*' doesn't work, b/c then it doesn't allow me to
> differentiate between instances.
> 
> Any guidance would be most welcome.
> 
> Thanks,
> mark
> 
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 



---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
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