Note that the CE "forall" in Drools must be applied to a set of facts. For
determining whether a List attribute fulfils some condition, the negated
existential quantifier might be applied.
p: Project()
not ( Integer( this <= 2 ) from p.list )
In some cases a direct test of the collection may be preferable:
p: Project( list contains 3 || contains 4 ) // contains element > 2 and < 5
Also note that Drools permits you to create custom evaluators so that
you might, for instance, create set test operations that can be applied to
all Collection type fields.
-W
for the list (Project - P; P.list), is each element is
On 3 Sep 2012, at 00:56, Phani Saripalli <saripalli.phani(a)gmail.com> wrote:
> Hi.
>
> I tried to identify relevant ways for some container specific operations
> like exists, forall (or foreach). Basically I have started using for
> software product line research, and specifically model checking over
> product
> line models. The initial results so fat ( considering the time I started)
> have been wonderful, alas I am tuck at this point.
>
>
> For example, consider :
> import java.util.List;
> import java.util.Arrays;
> import java.util.ArrayList;
>
> declare Project
> a : int
> b : int = 5
> list : List = new java.util.ArrayList(java.util.Arrays.asList(1 , 2 ,
> 3
> , 4 , 5))
> end
>
> Now that the element of Project - list is configured, I would like to
> perform some operations on it like:
> a) for each - for the list (Project - P; P.list), is each element is
> greater
> than 2? (or in essence - evaluating each element using a boolean
> expression).
>
> b) Similarly, a function like exists . for the list, is there any element
> for which this expression is satisfied -
> t > 2 && t < 5, where t is the iterator for the list.
p : Project()
exists( Number( this > 2 && < 5 ) from p.list )
>
> As the elements of the lists are mere numbers (in this case ints), I am
> not
> really aware/clear how I can use the Drools operations collect, for all
> etc.
>
> Previously I worked with Jess rule engine, and it has in built lambda
> functions which nicely provides list iterators and thus evaluating each
> element of the list against a boolean expression.
>
> I am at a very important point in my work, and any hint or solution will
> be
> highly appreciated.
>
> Many thanks :)
>
> Phani
>
>
>
> --
> View this message in context:
>
http://drools.46999.n3.nabble.com/Reg-Iterating-over-a-list-tp4019512.html
> 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
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users