On Thu, Sep 17, 2009 at 10:01 PM, Daniel Fischer <daniel.is.fisc...@web.de> wrote: > ... > readBit fn = do > txt <- readFile fn > let (l,_:bdy) = span (/= '\n') txt > return $ Bit (read l) bdy > > ? > > With > > main = do > args <- getArgs > let n = case args of > (a:_) -> read a > _ -> 1000 > bl <- mapM readBit ["file1.txt","file2.txt"] > mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > mapM_ (putStrLn . take 20 . drop n . body) bl
Yes, it *seems* to work but... the files don't get closed (readFile is unfinished until body is read) so I think I'm going to have problems when the number of files to read is higher than the maximum number of open handles a process can have. That's a possibility I considered even if not directly using readFile. Cristiano _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe