Skip to content

Instantly share code, notes, and snippets.

View MiyamonY's full-sized avatar
🏠
Working from home

MiyamonY

🏠
Working from home
View GitHub Profile
import System.IO()
main :: IO ()
main = do
contents <- readFile "baabaa.txt"
putStrLn contents
+ 95e725b... 06/07/15 04:08 public
d9c1b80... 05/27/15 23:45 public
36715d7... 05/27/15 11:44 public
a7fdff4... 03/25/15 21:09 public
494de2c... 03/25/15 20:39 public
0f26843... 03/25/15 20:38 public
f7844fc... 03/12/15 04:46 public haskell parser combinator
082478c... 03/07/15 17:17 public haskell StrConverter
a3598c7... 03/07/15 01:46 public haskell making monad
e7e1b18... 03/06/15 18:28 public haskell monad porland
main :: IO ()
main = interact respondPalidromes
respondPalidromes :: String -> String
respondPalidromes = unlines . map (\ xs -> if isPal xs then "palidrome" else "not a palidrome") . lines
isPal :: String -> Bool
isPal xs = xs == reverse xs
main :: IO ()
main = interact shortLinesOnly
shortLinesOnly :: String -> String
shortLinesOnly = unlines . filter (\ s -> length s < 10) . lines
main :: IO ()
main = do
contents <- getContents
putStr $ shortLinesOnly contents
shortLinesOnly :: String -> String
shortLinesOnly = unlines . filter (\ line -> length line < 10) . lines
-- lines :: String -> [String]
-- lines "aaa\nbbb\nccc" => ["aaa","bbb","ccc"]
import Control.Monad
import Data.Char
main :: IO ()
main = forever $ do
l <- getContents
putStrLn $ map toUpper l
import Control.Monad
import Data.Char
main :: IO ()
-- putStr
-- main = do
-- putStr "Hey, "
-- putStr "I'm "
-- putStr "Andy!"
-- putChar
import Control.Monad
import Data.Char
main :: IO ()
-- putStr
-- main = do
-- putStr "Hey, "
-- putStr "I'm "
-- putStr "Andy!"
-- putChar
main :: IO ()
main = do
a <- return "hell"
b <- return "yeah!"
putStrLn $ a ++ " " ++ b
-- main = do
-- let a = "hell"
-- b = "yeah"
-- putStrLn $ a ++ " " ++ b
main :: IO ()
main = do
return ()
return "HAHAHA"
line <- getLine
return "BLAH BLAH "
return 4
putStrLn line