Created
May 25, 2014 11:30
-
-
Save mdaisuke/7cb1c262b43c872ddec5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Main where | |
| import Data.Char | |
| main = interact capitalWords | |
| shortLinesOnly :: String -> String | |
| shortLinesOnly input = | |
| let allLines = lines input | |
| shortLines = filter (\line -> length line < 10) allLines | |
| result = unlines shortLines | |
| in result | |
| capitalWords :: String -> String | |
| capitalWords input = | |
| let allLines = lines input | |
| capitalWordLines = map capitalWordLine allLines | |
| result = unlines capitalWordLines | |
| in result | |
| capitalWordLine :: String -> String | |
| capitalWordLine line = | |
| let lineWords = words line | |
| capitalWords = map capital lineWords | |
| result = unwords capitalWords | |
| in result | |
| capital :: String -> String | |
| capital (x:xs) = toUpper x : xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment