IO recursion

mapple apple
Sat, 07 Apr 2001 14:36:50 +1000

Hi everyone,

I'm not sure this is the place to ask, coz I hvn't join your mailing
list. But anyway ..

Here's the case .. does anybody know 'bout IO recursion?
ie. We've a file and we want to put a numberline

1: 'first line'
2: 'second line'
until n, where n is the last line

I know how to convert a file into a huge string using 'readFile'
and I'm using the 'lines function' in the prelude.

That means i have a huge string like "\nHi mate\nHow r u?"
using the helper function 'lines' i can do that by saying :

main :: IO ()
main = do
             putStr "Filename plz: "
             file <- getLine
             content <- readFile file
             putStr ("1: " ++ read (show (head (lines content))))
             and so on

that's not recursive function and will not work for all cases.
So please .. if anyone knows how to do those things, let me know.

one more thing, does anybody know how to join the mailing list??

mapple apple
Get Your Private, Free E-mail from MSN Hotmail at