Anyway, these functions do not get the least fixed point ot r, but a fixed point of f starting from the seed x. it is'n?<div><br><div><a href="http://en.wikipedia.org/wiki/Fixed_point_(mathematics)">http://en.wikipedia.org/wiki/Fixed_point_(mathematics)</a></div>
<div><br></div><div><br></div><div><div class="gmail_quote">2009/3/19 Neil Mitchell <span dir="ltr"><<a href="mailto:ndmitchell@gmail.com">ndmitchell@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">> I've used a similar function myself, but why write it in such a complicated<br>
> way? How about<br>
><br>
> lfp :: Eq a => (a -> a) -> a -> a<br>
> lfp f x<br>
> | f x == x = x<br>
> | otherwise = lfp f (f x)<br>
<br>
</div>I've used a similar function too, but your version computes f x twice<br>
per iteration, I wrote mine as:<br>
't<br>
fix :: Eq a => (a -> a) -> a -> a<br>
fix f x = if x == x2 then x else fix f x2<br>
where x2 = f x<br>
<br>
I find this fix much more useful than the standard fix.<br>
<br>
Thanks<br>
<font color="#888888"><br>
Neil<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div></div>