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
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
+ 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
import System.IO()
main :: IO ()
main = do
contents <- readFile "baabaa.txt"
putStrLn contents
import System.IO ()
import Data.Char
main :: IO ()
main = do
contents <- readFile "baabaa.txt"
writeFile "baabaacaps.txt" (map toUpper contents)
import System.IO ()
main :: IO ()
main = do
todoItem <- getLine
appendFile "todo.txt" (todoItem ++ "\n")
import System.IO
import System.Directory
import Data.List
import Control.Exception
main :: IO ()
main = do
contents <- readFile "todo.txt"
let todoTasks = lines contents
numberedTasks = zipWith (\ n line -> show n ++ " - " ++ line)
import System.Environment
import Data.List
main :: IO ()
main = do
args <- getArgs
progName <- getProgName
putStrLn "The arguments are:"
mapM putStrLn args
putStrLn "The program name is:"
import System.Environment
import System.Directory
import System.IO
import Data.List
import Control.Exception
dispatch :: String -> [String] -> IO ()
dispatch "add" = add
dispatch "view" = view
dispatch "remove" = remove
import System.Random
threeCoins :: StdGen -> (Bool, Bool, Bool)
threeCoins gen =
let (firstCoin, newGen) = random gen
(secondCoin, newGen') = random newGen
(thirdCoin, _) = random newGen'
in (firstCoin, secondCoin, thirdCoin)
-- threeCoins (mkStdGen 100)
import System.Random
threeCoins :: StdGen -> (Bool, Bool, Bool)
threeCoins gen =
let (firstCoin, newGen) = random gen
(secondCoin, newGen') = random newGen
(thirdCoin, _) = random newGen'
in (firstCoin, secondCoin, thirdCoin)
-- threeCoins (mkStdGen 100)