Skip to content

Instantly share code, notes, and snippets.

@r-wheeler
Created September 21, 2015 17:36
Show Gist options
  • Save r-wheeler/de426d2fc707b2493435 to your computer and use it in GitHub Desktop.
Save r-wheeler/de426d2fc707b2493435 to your computer and use it in GitHub Desktop.
Reddit daily programmer
import Control.Monad
import Control.Arrow
isPalandrome :: [String] -> Bool
isPalandrome = reverse >>= (==)
process :: String -> Bool
process s = isPalandrome (take n t)
where (h,t) = (head &&& tail) $ lines s
n = read h :: Int
run :: String -> IO Bool
run = (liftM process . readFile)
main :: IO ()
main = run "test.text"
-- file contents:
-- 4
-- a
-- a
-- b
-- b
-- c
-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment