Advertisement
Guest User

Untitled

a guest
May 31st, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import qualified Data.ByteString.Lazy.Char8 as L
  2. import Control.Monad
  3. import System.IO
  4. import Data.IORef
  5.  
  6. hLines :: Handle -> IO [L.ByteString]
  7. hLines h = L.hGetContents h >>= pure . L.lines
  8.  
  9. main :: IO ()
  10. main = do
  11.   cnt <- newIORef 0
  12.   input <- hLines stdin
  13.   flip mapM_ input $ \line -> do
  14.     L.putStr line
  15.     modifyIORef cnt (+1)
  16.     cur <- readIORef cnt
  17.     if cur > 100
  18.       then L.putStr (input !! (cur - 100))
  19.       else return ()
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement