[rules-users] Reg. Iterating over a list

Mark Proctor mproctor at codehaus.org
Sun Sep 2 23:55:37 EDT 2012


On 3 Sep 2012, at 00:56, Phani Saripalli <saripalli.phani at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list