Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
-- deleteEmptyLine.hs
-- empty line delete and write file.
import System.Environment(getArgs)
filterEmptyLine :: [String] -> [String]
filterEmptyLine xs = [x | x <- xs, x /= ""]
addNewLine :: [String] -> [String]
addNewLine = map (\x -> x ++ "\n")
flatten :: [String] -> String
flatten = foldl (++) ""
main :: IO()
main = do
args <- getArgs
let arg = head args
text <- readFile arg
writeFile "write.txt" $ (flatten . addNewLine . filterEmptyLine . lines) text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment