Created
September 21, 2015 17:36
-
-
Save r-wheeler/de426d2fc707b2493435 to your computer and use it in GitHub Desktop.
Reddit daily programmer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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