[rules-users] Tree iteration with accumulate: is it possible ?

mcyrb cyrille.martins at thalesgroup.com
Thu Feb 28 12:59:17 EST 2013


Hello.

I have a tree, with each leaf containing a random value.
The value of each node is the sum of its children value.

I would like to write a rule which looks like this:
when
   nodeValue == 18 (e.g.)
then
   // do something with this node
end

The accumulate conditional element looked adequate for this, so I wrote
something like this
when
   n: Node()
   accumulate( Leaf( parentNode == n, v : value ); nodeValue : sum( v );
nodeValue == 18 )
then
   // do something with n
end

So... the problem is that this works only for nodes where its direct childs
are leafs, and not for upper nodes.
Have you got an idea to solve this ?

Thank you



--
View this message in context: http://drools.46999.n3.nabble.com/Tree-iteration-with-accumulate-is-it-possible-tp4022639.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list