Seasons.NET

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

Entries from 2006-06-24 to 1 day

ふつける練習問題その2

1 -- 標準入力から読んだワード数を数えるコマンド countWords 2 main = do cs <- getContents 3 print $ countWords $ lines cs 4 5 countWords :: [String] -> Int 6 countWords [ ] = 0 7 countWords (cs:c) = (length $ (words cs)) + countWords c

ふつける練習問題その1

本来の答えと違うかもしれないけど、こういうのもあり? 1 -- 標準入力から読んだバイト数を数えるコマンド countByte 2 main = do cs <- getContents 3 print $ countByte $ lines cs 4 5 countByte :: [String] -> Int 6 countByte [ ] = 0 7 countByte (c…