<br><br><div><span class="gmail_quote">On 4/5/06, <b class="gmail_sendername">ihope</b> &lt;<a href="mailto:ihope127@gmail.com">ihope127@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 4/5/06, Michael Goodrich &lt;<a href="mailto:michael.goodrich@gmail.com">michael.goodrich@gmail.com</a>&gt; wrote:<br>&gt; Looks like my calulation involves a self referential set of definitions.<br>&gt;<br>&gt;&nbsp;&nbsp;Is Haskell not able to deal with a self referential set of definitions?
<br><br>Yes, it is, but not if that definition doesn't evaluate to a &quot;proper&quot;<br>value. For example:<br><br>main = do<br>&nbsp;&nbsp;print x<br>&nbsp;&nbsp;where x = 3 * x^2<br><br>What do you expect this to do?<br><br>It may help if you toss us the offending code.
</blockquote><div><br>
<br>
<br>
I will be glad to.&nbsp; But just to make it more simple,&nbsp; it is a
recursive function with a self referential set of definitions&nbsp;that
builds a list like&nbsp; this :<br>
------------------------------------------------------------------------------------------------------------<br>
<br>
&nbsp;foo&nbsp; (step,r0,mu0) = bar (step,r1,r0,mu1,mu0)
<br>
&nbsp;&nbsp;&nbsp; where
<br>
&nbsp;&nbsp;&nbsp; r1 = r0-step*rd
<br>
&nbsp;&nbsp;&nbsp; mu1 = mu0-step*mud
<br>
&nbsp;&nbsp;&nbsp; rd = c*c*mu0
<br>
&nbsp;&nbsp;&nbsp; mud = c*c/r0 - (foobar_r z)/c<br>
&nbsp;&nbsp;&nbsp; c = baz(z)<br>
&nbsp;&nbsp;&nbsp; z = 6.378388e6-r0
<br>
&nbsp;<br>
baz z | z&lt;125 = -0.25*z+1537.5
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; | otherwise = 0.0169*z+1504.1
<br>
&nbsp;<br>
foobar_r z | z&lt;125 = 0.25
<br>
&nbsp;&nbsp;&nbsp; | otherwise = -0.0169
<br>
&nbsp;<br>
bar (step,r2,r1,mu2,mu1) = (r,z0) : bar (step,r1,r,mu1,m)
<br>
&nbsp;&nbsp;&nbsp; where
<br>
&nbsp;&nbsp;&nbsp; r = r2+2*step*rdc
<br>
&nbsp;&nbsp;&nbsp; m = mu2+2*step*mudc
<br>
&nbsp;&nbsp;&nbsp; rdc = (rd2+rd1+rd0)/6
<br>
&nbsp;&nbsp;&nbsp; mudc = (mud2+mud1+mud0)/6
<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; rd2 = c2*c2*mu2
<br>
&nbsp;&nbsp;&nbsp; mud2 = c2*c2/r2 - (foobar_r z2)/c2
<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; rd1 = c1*c1*mu1
<br>
&nbsp;&nbsp;&nbsp; mud1 = c1*c1/r1 - (foobar_r z1)/c1
<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; rd0 = c0*c0*m
<br>
&nbsp;&nbsp;&nbsp; mud0 = c0*c0/r - (foobar_r z0)/c0
<br>
<br>
&nbsp;&nbsp;&nbsp; c2 = baz(z2)
<br>
&nbsp;&nbsp;&nbsp; c1 = baz(z1)
<br>
&nbsp;&nbsp;&nbsp; c0 = baz(z0)<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; z2 = 6.378388e6-r2
<br>
&nbsp;&nbsp;&nbsp; z1 = 6.378388e6-r1
<br>
&nbsp;&nbsp;&nbsp; z0 = 6.378388e6-r
<br>
&nbsp;<br>
main :: IO ()
<br>
main = do
<br>
&nbsp;&nbsp;&nbsp; print $ take 100 (foo (0.1, 6.378388e6,0))
<br>
&nbsp;<br>
<br>
</div><br></div><br>