<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Works like a charm. Here's a final copy for those interested.<br><br>Michael<br><br>=====<br><br>import Data.Ratio<br>cf2 :: Rational -&gt; [Int]<br>cf2 a = let ai = floor a<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; air = toRational ai<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in ai : if a == air then [] else cf2 (1 / (a - air))<br><br><br><br>--- On <b>Sun, 3/29/09, Miguel Mitrofanov <i>&lt;miguelimo38@yandex.ru&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Miguel Mitrofanov &lt;miguelimo38@yandex.ru&gt;<br>Subject: Re: [Haskell-cafe] Rational and % operator remix<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: "Lennart Augustsson" &lt;lennart@augustsson.net&gt;, haskell-cafe@haskell.org<br>Date: Sunday, March 29, 2009, 4:25 PM<br><br><div
 class="plainMail">cf2 a = let ai = floor a<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; air = toRational ai<br>&nbsp; &nbsp; &nbsp; &nbsp; in ai : if a == air then [] else cf2 (1 / (a - air))<br><br>On 30 Mar 2009, at 00:19, michael rice wrote:<br><br>&gt; I'm a Lisper, kind of feeling my way around here in Haskell, so please bear with me.<br>&gt; <br>&gt; I did the things you suggested, but I think the last one may have gotten garbled. Anyway, this is what I ended up with<br>&gt; <br>&gt; cf2 :: Rational -&gt; [Int]<br>&gt; cf2 a = let ai = floor a<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;in<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;if a == (toRational ai)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;then [ai]<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;else ai : cf2 (1 / (a - ai))<br>&gt; <br>&gt; but I'm still at least one error short of a clean
 run<br>&gt; <br>&gt; Main&gt; :load cf.hs<br>&gt; ERROR "cf.hs":7 - Type error in application<br>&gt; *** Expression&nbsp; &nbsp;&nbsp;&nbsp;: ai : cf2 (1 / (a - ai))<br>&gt; *** Term&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;: ai<br>&gt; *** Type&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;: Ratio Integer<br>&gt; *** Does not match : Int<br>&gt; <br>&gt; <br>&gt; Where did I go wrong or what did I leave out?<br>&gt; <br>&gt; Michael<br>&gt; <br>&gt; <br>&gt; --- On Sun, 3/29/09, Lennart Augustsson &lt;<a ymailto="mailto:lennart@augustsson.net" href="/mc/compose?to=lennart@augustsson.net">lennart@augustsson.net</a>&gt; wrote:<br>&gt; <br>&gt; From: Lennart Augustsson &lt;<a ymailto="mailto:lennart@augustsson.net" href="/mc/compose?to=lennart@augustsson.net">lennart@augustsson.net</a>&gt;<br>&gt; Subject: Re: [Haskell-cafe] Rational and % operator remix<br>&gt; To: "michael rice" &lt;<a ymailto="mailto:nowgate@yahoo.com"
 href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;<br>&gt; Cc: <a ymailto="mailto:haskell-cafe@haskell.org" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>&gt; Date: Sunday, March 29, 2009, 2:29 PM<br>&gt; <br>&gt; You can use floor in a Rational directly, no need to take it apart and divide.<br>&gt; <br>&gt; There is no need to write (toRational 1), just write 1.<br>&gt; <br>&gt; Don't write (subtract ai a), write (ai - i).<br>&gt; <br>&gt; You also have a type error; the ai should no be a Rational, so you<br>&gt; need to move to toRational call to the comparison.<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;-- Lennart<br>&gt; <br>&gt; 2009/3/29 michael rice &lt;<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;:<br>&gt; &gt; Hi,<br>&gt; &gt;<br>&gt; &gt; Thanks again for the help last night.<br>&gt; &gt;<br>&gt; &gt; The second function cf2 is an attempt to
 reverse the process of the first<br>&gt; &gt; function, i.e., given a rational number it returns a list of integers,<br>&gt; &gt; possibly infinite, but you shouldn't get into trouble if you use 98%67 as<br>&gt; &gt; input (output should be [1,2,6,5]). The interpreter is complaining about the<br>&gt; &gt; '=' following the 'in' keyword. Is there a better way to state this?<br>&gt; &gt;<br>&gt; &gt; Michael<br>&gt; &gt;<br>&gt; &gt; import Data.Ratio<br>&gt; &gt; cf :: [Int] -&gt; Rational<br>&gt; &gt; cf (x:[]) = toRational x<br>&gt; &gt; cf (x:xs) = toRational x + 1 / cf xs<br>&gt; &gt;<br>&gt; &gt; cf2 :: Rational -&gt; [Int]<br>&gt; &gt; cf2 a = let ai = toRational (floor ((numerator a) / (denominator a)))<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;in<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;if a = ai<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;then [a]<br>&gt;
 &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;else ai : cf2 ((toRational 1) / (subtract ai a))<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; Haskell-Cafe mailing list<br>&gt; &gt; <a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>&gt; &gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>&gt; &gt;<br>&gt; &gt;<br>&gt; <br>&gt; _______________________________________________<br>&gt; Haskell-Cafe mailing list<br>&gt; <a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe"
 target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br><br></div></blockquote></td></tr></table><br>