The program below takes a text file and unwraps all lines to 72 columns, but
I'm getting an end of file message at the top of my output.
How do I lose the EOF?
Michael
====== unwrap.hs ======
main = do
line <- getLine
if null line
then do
putStrLn ""
main
else
do
printList (words line) 1
main
printList :: [String] -> Int -> IO ()
printList [] _ = do putStrLn ""
printList (w:[]) k = do
if k+(length w) <= 72
then do
putStrLn w
else do
putStrLn ""
putStrLn w
printList r@(w:ws) k = do
if k+(length w) <= 72
then do
putStr w
putStr " "
printList ws (k+(length w)+1)
else do
putStrLn ""
printList r 1
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe