varikvalefor, root@nerva:~# cat /root/prgs/horatio-ratio.hs
import Control.Monad;
import System.Environment;blah :: Bool -> [String] -> (Int, Int, Int, Int);
blah _ [] = (0 , 0, 0, 0);
blah _ ("\begin{code}" : xs) = blah True xs;
blah _ ("\end{code}" : xs) = blah False xs;
blah True (t : xs) = addCode $ blah True xs
where {
addCode (a , b , c , d) = (a, b+1, c, d + length t);
}
blah False (t : xs) = addNot $ blah False xs
where {
addNot (a, b, c, d) = (a + 1, b, c + length t, d);
}main = (>>=) getArgs $ mapM $ readFile >=> print . blah False . lines;