<br><br><div><span class="gmail_quote">On 4/5/06, <b class="gmail_sendername">ihope</b> <<a href="mailto:ihope127@gmail.com">ihope127@gmail.com</a>> 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 <<a href="mailto:michael.goodrich@gmail.com">michael.goodrich@gmail.com</a>> wrote:<br>> Looks like my calulation involves a self referential set of definitions.<br>><br>> 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 "proper"<br>value. For example:<br><br>main = do<br> print x<br> 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. But just to make it more simple, it is a
recursive function with a self referential set of definitions that
builds a list like this :<br>
------------------------------------------------------------------------------------------------------------<br>
<br>
foo (step,r0,mu0) = bar (step,r1,r0,mu1,mu0)
<br>
where
<br>
r1 = r0-step*rd
<br>
mu1 = mu0-step*mud
<br>
rd = c*c*mu0
<br>
mud = c*c/r0 - (foobar_r z)/c<br>
c = baz(z)<br>
z = 6.378388e6-r0
<br>
<br>
baz z | z<125 = -0.25*z+1537.5
<br>
| otherwise = 0.0169*z+1504.1
<br>
<br>
foobar_r z | z<125 = 0.25
<br>
| otherwise = -0.0169
<br>
<br>
bar (step,r2,r1,mu2,mu1) = (r,z0) : bar (step,r1,r,mu1,m)
<br>
where
<br>
r = r2+2*step*rdc
<br>
m = mu2+2*step*mudc
<br>
rdc = (rd2+rd1+rd0)/6
<br>
mudc = (mud2+mud1+mud0)/6
<br>
<br>
rd2 = c2*c2*mu2
<br>
mud2 = c2*c2/r2 - (foobar_r z2)/c2
<br>
<br>
rd1 = c1*c1*mu1
<br>
mud1 = c1*c1/r1 - (foobar_r z1)/c1
<br>
<br>
rd0 = c0*c0*m
<br>
mud0 = c0*c0/r - (foobar_r z0)/c0
<br>
<br>
c2 = baz(z2)
<br>
c1 = baz(z1)
<br>
c0 = baz(z0)<br>
<br>
z2 = 6.378388e6-r2
<br>
z1 = 6.378388e6-r1
<br>
z0 = 6.378388e6-r
<br>
<br>
main :: IO ()
<br>
main = do
<br>
print $ take 100 (foo (0.1, 6.378388e6,0))
<br>
<br>
<br>
</div><br></div><br>