Hi!
> this may seem a trivial problem, but I hope you can help out.
> As far as I understood, the general way to describe production rules
> is like this:
>
> a and b and c ... => execute x
>
> From what I have understood about RETE there is no efficiency problem
> in defining a second rule, if the negation of some fact is used:
>
> a and b and not c ... => execute x
>
> because this will be just a second branch to the rule above. However,
> if c contains e.g. a method call to java, the method is called twice,
> right?
That's right!
> At the moment I solve this by producing a fact containing the result
> of the method and then have two rules working on this fact expressing
> both branches. But this seems rather inelegant and inefficient. Can
> anybody enlighten me?
Let's say you have three patterns (a), (b), and (c), where (c) is actually (test
(java-method-call)). Then you can also write
(defrule my-rule
(a)
(b)
=>
(if (java-method-call) then
(execute-then-case)
else
(execute-else-case)))
Usually, you should avoid having if-then-else constructs on the RHS that do the work
of the pattern matcher. But in this case, it should be more efficient.
Thomas
---------------------------------------------------------------------
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]
---------------------------------------------------------------------