2006-09-25から1日間の記事一覧

四章のまとめ

関数 unwords xs any f xs filter f xs head xs tail xs List.tails xs xs `List.isPrefixOf` ys アクション System.getArgs

fgrep

import System import List main = do args <- getArgs cs <- getContents putStr $ fgrep (head args) cs fgrep :: String -> String -> String fgrep pattern cs = unlines $ filter match $ lines cs where match :: String -> Bool match line = any pre…

echo

{- Haskell -} import System main = do args <- getArgs putStrLn $ unwords args モジュール すべての関数や変数はモジュールに所属する import宣言でインポートする Main module main変数を含むモジュール デフォルトでは、外部にmain変数だけを公開 Prel…