
1 Nov
2004
1 Nov
'04
12:52 p.m.
Hi! I'm newbie and I don't understand how to process large files in haskell with constant memory requirements. For example, to count numbers of different words in text file I wrote following program: -- start import System.Environment merge [] x = [(x,1)] merge (e@(a,b):xs) x | x == a = (a,b+1):xs | otherwise = e : merge xs x procFile = putStrLn . show . foldl merge [] . words main = do args <- getArgs readFile (head args) >>= procFile -- end How should I modify it to make it useful on large file? It eats too much memory... -- Alexander Kogan Auto Wave Processes Group Institute of Applied Physics RAS