Skip to content

Instantly share code, notes, and snippets.

@masaedw
Forked from kana/date.hs
Created February 9, 2011 15:19
Show Gist options
  • Save masaedw/818620 to your computer and use it in GitHub Desktop.
Save masaedw/818620 to your computer and use it in GitHub Desktop.
import System.Time
import System.Locale
main = getClockTime >>=
toCalendarTime >>=
putStrLn . formatCalendarTime defaultTimeLocale "%c"
import System.Environment
main = getArgs >>= putStrLn . unwords
import System.Exit
main = exitFailure
import System.Directory
main = getCurrentDirectory >>= putStrLn
import Data.List
main = getContents >>= putStrLn . unlines . sort . lines
import System.Environment
main :: IO ()
main = do
args <- getArgs
s <- getContents
tee args s
teeProc :: [String -> IO ()] -> String -> IO()
teeProc procs content = mapM_ feed procs
where
feed proc = proc content
tee :: [String] -> String -> IO ()
tee args = teeProc $ putStr : map writeFile args
import System.Exit
main = exitWith ExitSuccess
main = getContents >>= \x -> putStrLn $ unlines $ uniq $ lines x
uniq :: (Eq a) => [a] -> [a]
uniq [] = []
uniq (x:[]) = [x]
uniq (x:xs) = if x == head xs then uniq xs else x:(uniq xs)
import System.Environment
main = getArgs >>= putStrLn . yes
yes :: [String] -> String
yes xs = unlines $ repeat $ unwords $ normalizeArguments xs
normalizeArguments :: [String] -> [String]
normalizeArguments [] = ["y"]
normalizeArguments xs = xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment