<div dir="ltr">It just means you are trying to directly access a list element by its index in a list that doesn&#39;t have that many elements.  It is probably somewhere in your floatData function, which you did not list.  When you don&#39;t print it out to screen, haskell does not bother to evaluate it and therefore it never hits that error.  If you didn&#39;t use that operator, then it is used in some library you are using.<br>
<br>Prelude&gt; [1,2,3] !! 5<br>*** Exception: Prelude.(!!): index too large<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 4, 2013 at 1:49 PM, Roger Mason <span dir="ltr">&lt;<a href="mailto:rmason@mun.ca" target="_blank">rmason@mun.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
The following fragment compiles but causes a runtime error:<br>
<br>
Prelude.(!!): index too large<br>
<br>
If I comment out the line &#39;hPutStr outh ( show ncat)&#39; the program runs fine (but there is no output, of course).<br>
<br>
Thanks for any help.<br>
<br>
Roger<br>
<br>
writeOutput infile outfile list fox mw nox ncat units = do<br>
          inh &lt;- openFile infile ReadMode -- the file of analyses, one per line<br>
          outh &lt;- openFile outfile WriteMode<br>
          mainloop inh outh list fox mw nox ncat units<br>
          hClose outh<br>
          hClose inh<br>
<br>
-- the calculations are here<br>
mainloop inh outh list fox mw nox ncat units = do<br>
             ineof &lt;- hIsEOF inh<br>
             if ineof<br>
                     then do<br>
                         print list      -- For testing/debugging only<br>
                         return ()<br>
                     else do<br>
                   inpStr &lt;- hGetLine inh<br>
                   let list&#39; = inpStr:list<br>
                           let dat = floatData list&#39; -- the analytical input data<br>
                           let ta = zipWith (/) dat units                            -- convert all to wt%<br>
                           let moles = zipWith (/) ta mw<br>
                           let apo = zipWith (*) nox moles<br>
                           let factor = fox/(sum apo)<br>
                           let nanions= (map (* factor) apo)<br>
                           let catox = zipWith (/) ncat nox<br>
                           let ncat = zipWith (*) catox nanions<br>
                           hPutStr outh ( show ncat)<br>
                   mainloop inh outh list&#39; fox mw nox ncat units<br>
<br>
This electronic communication is governed by the terms and conditions at<br>
<a href="http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php" target="_blank">http://www.mun.ca/cc/policies/<u></u>electronic_communications_<u></u>disclaimer_2012.php</a><br>
<br>
______________________________<u></u>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>