Seasons.NET

ちょっとした技術ブログです

Entries from 2006-06-25 to 1 day

ふつける練習問題その5

1 -- 同じ行が連続していたらまとめるコマンド uniq を作成しなさい 2 import List 3 import System 4 5 -- 割と読みやすいほう 6 main = do args <- getArgs 7 contents <- readFile (head args) 8 putStrLn $ unlines $ groupLines $ lines contents 9 10 …

ふつける練習問題その4

1 -- リストをソートする 2 import List 3 import System 4 5 main = do args <- getArgs 6 contents <- readFile (head args) 7 putStrLn $ unlines $ sortLine $ lines contents 8 9 sortLine :: [String] -> [String] 10 sortLine cs = sort cs

ふつける練習問題その3

1 --- 標準入力から読み込んだ 'a'と'A'を入れ替えるコマンド swapA 2 import System 3 4 main = do cs <- getArgs 5 print $ map swapA (concat cs) 6 7 swapA :: Char -> Char 8 swapA 'a' = 'A' 9 swapA 'A' = 'a' 10 swapA c = c