Hi!
> I would like to have a rule work on multiple instances of an object
> i.e. multiple instances on the LHS. Now do I have to do
>
> Pop[] pop = new Pop[100];
> Funcall f = new Funcall("definstance", rete);
> f.add(new Value("pop", RU.ATOM));
> f.add(new Value(pop[0]));
> f.execute(rete.getGlobalContext());
>
> for each instance. Can I use a pattern to assert all instances of Pop
> object. If I can do it, how do I represent it in the rule.
I'm not sure whether I understand what you mean.
What does the rule look like? Version 1 or 2?
;; Version 1
(defrule rule-1
(pop (OBJECT ?o-1) ...)
=>
;; RHS
)
;; Version 2
(defrule rule-2
(pop (OBJECT ?o-1) ...)
...
(pop (OBJECT ?o-n) ...)
=>
;; RHS
)
No matter what kind of rule you have, you need to create instances one by one. You can
reuse the same Funcall object for every instance, though:
// Create objects
Pop[] pop = new Pop[100];
...
// Prepare Funcall
Funcall f = new Funcall("definstance", rete);
f.setLength(3);
f.set(new Value("pop", RU.ATOM), 1);
// Modify Funcall and create instances
for (int i = 0 ; i < 100 ; i++) {
f.set(new Value(pop[i]), 2);
f.execute(rete.getGlobalContext());
}
Greetings, 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]
---------------------------------------------------------------------