Created
August 14, 2012 14:04
-
-
Save tanakh/3349522 to your computer and use it in GitHub Desktop.
行カウント ref: http://qiita.com/items/de39d121ad61594c45dc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Monad | |
| import qualified Data.ByteString.Lazy.Char8 as L | |
| import System.Environment | |
| main :: IO () | |
| main = go False =<< getArgs where | |
| go _ ("-f": rest) = go True rest | |
| go _ [] = print . gyo =<< L.getContents | |
| go _ ["-"] = print . gyo =<< L.getContents | |
| go f files = forM_ files $ \file -> do | |
| ln <- return . gyo =<< L.readFile file | |
| if f | |
| then putStrLn $ file ++ " " ++ show ln | |
| else putStrLn $ show ln ++ " " ++ file | |
| gyo :: L.ByteString -> Int | |
| gyo = length . L.lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment