Hi!<br><br><div class="gmail_quote">2010/9/2 Eoin C. Bairéad <span dir="ltr">&lt;<a href="mailto:ebairead@gmail.com">ebairead@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Example 2<br>
<br>
Prelude&gt; let fac n = if n == 0 then 1 else n * fac (n-1)<br>
<br>
How does it know to stop ?<br></blockquote><div><br>When fac is called with n=0 it returns 1 and stops the recursion.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


and why does fac 2.5 hang?<br></blockquote></div><br>fac, as you defined it, is only defined for integers. As you repeatedly subtract 1 from n you will never get to 0 (you will get to 0.5 and then -0.5) and thus the recursion will never terminate.\<br>

<br>