
On Sun, Dec 25, 2005 at 12:24:38PM +0100, Peter Simons wrote:
Paul Moore writes:
It would be interesting to see standalone code for wcIOB (where you're allowed to assume that any helpers you need, like your block IO library, are available from the standard library). This would help in comparing the "obviousness" of the two approaches.
A simple version of the program -- which doesn't need any 3rd party modules to compile -- is attached below. My guess is that this approach to I/O is quite obvious, too, if you have experience with system programming in C.
IMHO, the main point of the example in the article is that
wc :: String -> (Int, Int, Int) wc file = ( length (lines file) , length (words file) , length file )
is a crapy word-counting algorithm.
I have a crazy idea: what if we computed all three length applications concurrently, with the RTS preempting the thread when it generates too much unreclaimable nodes? Do you know what I mean? The ideal effect would be that the three threads chase each other on the list, there is always only a constant part of the list in memory (no space-leak). Best regards Tomasz -- I am searching for a programmer who is good at least in some of [Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland