[rules-users] Writing complicated rules - consecutive number problem

Swindells, Thomas TSwindells at nds.com
Mon Nov 7 03:29:15 EST 2011


Something like this may work?

p : Person() //for any person
exists( Person(age < p.age)) //who has someone younger than them
not (Person(age == p.age-1)) //there must be someone 1 year younger than them.
then
//there is a gap
end

if you only want it to fire once then you may need an extra exists around it or something.

Thomas

> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org [mailto:rules-users-
> bounces at lists.jboss.org] On Behalf Of LCode
> Sent: 05 November 2011 15:16
> To: rules-users at lists.jboss.org
> Subject: [rules-users] Writing complicated rules - consecutive number
> problem
>
> I am trying to write a rather complicated rule via the guided rule editor and I
> wonder if it is indeed possible.
>
> The following is a simplified explanation of my scenario:
>
>
> A 'person' has a numerical property 'age'
>
>
> In a hypothetical world the following is allowed because the ages of the
> people are consecutive:
>
> Person A age = 24
>
> Person B age = 25
>
> Person C age = 26     OK
>
> Person D age = 27
>
>
> However I would like to write a rule that fires if the ages are not consecutive,
> something like this:
>
> Person A age = 24
>
> Person B age = 25
>
> Person C age = 29     NOT OK
>
> Person D age = 27
>
>
>
> I am starting with 'From collect all people [p]'.
>
>
> Any thoughts, comments or similar experiences much apprieciated as I am
> pulling my hair out!
> Jen
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Writing-
> complicated-rules-consecutive-number-problem-tp3482704p3482704.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


**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************




More information about the rules-users mailing list