-- file: wc.hs wordsCount[] = 0 wordsCount(x:xs) = length(words(x)) + wordsCount(xs) charCount[] = 0 charCount(x:xs) = length(x) + 1 + charCount(xs) -- count the newline main = interact wordCount where wordCount input = show (length (lines input)) ++ " lines\n" ++ show (wordsCount (lines input)) ++ " words\n" ++ show (charCount (lines input)) ++ " characters\n"