<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">This seems to work:<br><br>import Data.Ratio<br>cf :: [Integer] -&gt; Rational<br>cf (x:[]) = toRational x<br>cf (x:xs) = toRational x + (1 / cf xs)<br><br>Hugs&gt; :load cf.hs<br>Main&gt; cf [1,2,6,5]<br>98 % 67<br>Main&gt; cf [2,3]<br>7 % 3<br>Main&gt; <br><br>Thanks, guys!<br><br>Michael<br><br><br>--- On <b>Sun, 3/29/09, Luke Palmer <i>&lt;lrpalmer@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Luke Palmer &lt;lrpalmer@gmail.com&gt;<br>Subject: Re: [Haskell-cafe] type Rational and the % operator<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: "Ryan Ingram" &lt;ryani.spam@gmail.com&gt;, haskell-cafe@haskell.org<br>Date: Sunday, March 29, 2009, 12:23 AM<br><br><div id="yiv1983335065"><div class="gmail_quote">2009/3/28 michael rice <span dir="ltr">&lt;<a
 rel="nofollow" ymailto="mailto:nowgate@yahoo.com" target="_blank" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" valign="top">Still the same problem. The book says the answer is supposed to be an exact 98/67.<br><br>Michael<div class="im"><br>
<br>
import Data.Ratio<br>
cf :: [Integer] -&gt; Rational<br></div>
cf (x:xs) = (x % 1) + (1 % (cf xs))<br>
cf (x:[]) = x % 1<br>
cf [] = 0 % 1</td></tr></tbody></table></blockquote><div><br></div><div>Use (/) for division:</div><div><br></div><div>cf :: [Integer] -&gt; Rational</div><div>cf (x:xs) = toRational x + 1 / cf xs</div><div>cf [x] = toRational x</div>
<div>cf [] = 0</div><div><br></div><div>Luke</div></div>
</div></blockquote></td></tr></table><br>