Skip to content

Instantly share code, notes, and snippets.

@mdaisuke
Created May 25, 2014 11:30
Show Gist options
  • Select an option

  • Save mdaisuke/7cb1c262b43c872ddec5 to your computer and use it in GitHub Desktop.

Select an option

Save mdaisuke/7cb1c262b43c872ddec5 to your computer and use it in GitHub Desktop.
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