On 21/07/2012, salt <writemesaltworth(a)gmail.com> wrote:
Hi Laune,
Thanks for your comments. But i am not allowed to use eval() as that also
might have performance issues.
Who forbids this? Bah.
Actually this is my problem,
$order:Order() Transaction() from $order.transaction
if the list contains A,B,C,D,E,F
Not very lucid.
Please let me know whether nested loops are possible.
There are no "loops" in DRL in the sense you appear to be thinking,
i.e., procedurally.
Here's how to do it:
function boolean cd( List list, Integer c, Integer d ){
int cPos = list.indexOf( c );
return cPos != -1 ? list.subList(cPos+1, list.size()).indexOf d)
!= -1 : false;
}
rule cd
when
$l: List()
Pair( $c: c, $d: d )
eval( cd( $l, $c, $d ) )
then
end
This takes, on the average, 0.000014s (2.80GHz) per evaluation for
random combinations of elements that are actually in the list (and a
little less if one or both aren't contained). List length doesn't
really matter; for a list with 1000 elements the average is 0.000016s.
-W
Thanks for your support.
--
View this message in context:
http://drools.46999.n3.nabble.com/NESTED-LOOPS-Possible-tp4018811p4018814...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users