
Hello, The following fragment compiles but causes a runtime error: Prelude.(!!): index too large If I comment out the line 'hPutStr outh ( show ncat)' the program runs fine (but there is no output, of course). Thanks for any help. Roger writeOutput infile outfile list fox mw nox ncat units = do inh <- openFile infile ReadMode -- the file of analyses, one per line outh <- openFile outfile WriteMode mainloop inh outh list fox mw nox ncat units hClose outh hClose inh -- the calculations are here mainloop inh outh list fox mw nox ncat units = do ineof <- hIsEOF inh if ineof then do print list -- For testing/debugging only return () else do inpStr <- hGetLine inh let list' = inpStr:list let dat = floatData list' -- the analytical input data let ta = zipWith (/) dat units -- convert all to wt% let moles = zipWith (/) ta mw let apo = zipWith (*) nox moles let factor = fox/(sum apo) let nanions= (map (* factor) apo) let catox = zipWith (/) ncat nox let ncat = zipWith (*) catox nanions hPutStr outh ( show ncat) mainloop inh outh list' fox mw nox ncat units This electronic communication is governed by the terms and conditions at http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php