• 追加された行はこの色です。
  • 削除された行はこの色です。
* cat by foldM [#o471dc62]

 import Control.Monad(foldM)
 import System.Environment(getArgs)
 
 -- readFile :: FilePath -> IO String
 -- getArgs :: IO [String]
 -- foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a
 -- see http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#v%3AfoldM
 
 freadAppend :: String -> FilePath -> IO String
 freadAppend x f = do
   str <- readFile f
   return $ x++str
 
 main :: IO ()
 main = do
   files <- getArgs
   str <- foldM freadAppend "" files
   putStrLn str

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS