<div dir="ltr"><div>I am having difficulty in evaluating conditionals where more than one case is true.</div><div>I require a program to express the following conditions:</div><div> 1) x is faster than y if x is a buffolo and y is a pig.</div><div> 2) x is faster than y if x is a pig and y is a slug.</div><div>Both of these conditions are true (expressed in fact predicate).</div><div>I include my attempt using guards (I have also tried case/if-then-else)</div><div><br></div><div>I can apreciate that the program works when the first guard condition is met (faster Bob Joe).</div><div>I am not sure why it fails on the second case (faster Bob Joe)</div><div><br></div><div>Can I program the requirement using conditionals?</div><div>Can I pattern match is some way?</div><div>Is there another way to encode the requirement.</div><div>Regards,</div><div>Pat</div><div><br></div><div><br></div><div>data E = Bob | Joe | Steve | Buffalo | Pig | Slug  deriving Show</div><div><br></div><div>fact Buffalo Bob  = True </div><div>fact Pig Joe  = True </div><div>fact Slug Steve  = True </div><div><br></div><div><br></div><div>faster x y | fact Buffalo x && fact Pig y =  True </div><div>           | fact Pig x && fact Slug y =  True </div><div>           | otherwise = False</div><div>-- faster Bob Joe OK</div><div>-- faster Steve  Bob ***Exception: Faster.hs:(5,1)-(7,23): Non-exhaustive patterns in function fact</div></div>

<br>
<p><span lang="EN-GB"><font size="2">This email originated from DIT. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited. <a href="http://www.dit.ie/" target="_blank">www.dit.ie</a></font></span></p><p><font size="2">Is ó ITBÁC
a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí earráid, scrios
de do chóras é le do thoil. Tabhair ar aird, mura tú an seolaí ainmnithe, go
bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon dáileadh nó ar aon ghníomh
a dhéanfar bunaithe ar an ábhar atá sa ríomhphost nó sna hiatáin seo. <a href="http://www.dit.ie/" target="_blank">www.dit.ie</a></font></p><p><a href="http://www.dit.ie/grangegorman" target="_blank"><font size="2">Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to Grangegorman</font></a></p>