<font size="2"><p>Beautiful!<br><br>How would a business user (non-programmer) write such a rule. The only way I can think of is create a dsl sentence for this specific condition<br></p></font><hr><font size="2"><p><b>&nbsp; From: </b>Wolfgang Laun [wolfgang.laun@gmail.com]<br><b>&nbsp; Sent: </b>02/09/2012 05:02 PM CET<br><b>&nbsp; To: </b>Rules Users List &lt;rules-users@lists.jboss.org&gt;<br><b>&nbsp; Subject: </b>Re: [rules-users] How do I write a rule to detect a missing value in a group of facts?<br></p></font><br>
<div>Don&#39;t think procedurally, just write the *rule* for a missing post ;-)</div><div><br></div>rule &quot;missing fence post&quot;<div>when</div><div>    FencePost( $d: distanceFromStart )</div><div>    FencePost( distanceFromStart == $d + 2*FencePost.GAP )<br>
    not FencePost( distanceFromStart == $d + FencePost.GAP )<br>then</div><div>    System.out.println( &quot;Missing: &quot; + ($d + FencePost.GAP) );</div><div>end</div><div><br></div><div>-W<br><br><div class="gmail_quote">
On 9 February 2012 16:41, mikeg <span dir="ltr">&lt;<a href="mailto:mike@thegoldners.com">mike@thegoldners.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I need to write a rule to identify a missing element in a group of facts.<br>
<br>
For example, let us say I want to ensure that my fence has a fence post<br>
every 8 feet.  My fact declaration is as follows:<br>
<br>
declare FencePost<br>
  identifier : String<br>
  distanceFromStart: Long<br>
end<br>
<br>
If I add the following facts into my session:<br>
<br>
FencePost(&quot;a&quot;, 0)<br>
FencePost(&quot;x&quot;, 8)<br>
FencePost(&quot;e&quot;, 24)<br>
<br>
I want a rule that will notify the user that there is a missing fence post<br>
between &quot;x&quot; and &quot;e&quot;.<br>
<br>
I&#39;ve been looking into using &quot;collect&quot; into a TreeSet/TreeMap to get a<br>
collection sorted on the &quot;distanceFromStart&quot;, but I cannot figure out how to<br>
compare adjacent elements in the collection.<br>
<br>
Any ideas?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/How-do-I-write-a-rule-to-detect-a-missing-value-in-a-group-of-facts-tp3729818p3729818.html" target="_blank">http://drools.46999.n3.nabble.com/How-do-I-write-a-rule-to-detect-a-missing-value-in-a-group-of-facts-tp3729818p3729818.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></span></blockquote></div><br></div>


-----------------------------------------
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you