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