Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
import Control.Concurrent
|
||||
import Control.Concurrent.MVar
|
||||
|
||||
main =
|
||||
do lineVar <- newEmptyMVar
|
||||
countVar <- newEmptyMVar
|
||||
|
||||
let takeLine = takeMVar lineVar
|
||||
putLine = putMVar lineVar . Just
|
||||
putEOF = putMVar lineVar Nothing
|
||||
takeCount = takeMVar countVar
|
||||
putCount = putMVar countVar
|
||||
|
||||
forkIO $ writer takeLine putCount
|
||||
reader putLine putEOF takeCount
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
reader putLine putEOF takeCount =
|
||||
do ls <- fmap lines (readFile "input.txt")
|
||||
mapM putLine ls
|
||||
putEOF
|
||||
n <- takeCount
|
||||
print n
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
writer takeLine putCount = loop 0
|
||||
where loop n = do l <- takeLine
|
||||
case l of
|
||||
Just x -> do putStrLn x
|
||||
loop (n+1)
|
||||
Nothing -> putCount n
|
||||
Loading…
Add table
Add a link
Reference in a new issue