Last active
August 29, 2015 13:58
-
-
Save MichaelBlume/10347711 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/runhaskell | |
import Data.Char | |
translate_char tmap c = helper tmap where | |
helper [] = c | |
helper ((c',ct):ps) | |
| c == c' = ct | |
| otherwise = helper ps | |
translate_string tmap = map $ translate_char tmap | |
cipher_helper s = do | |
putStrLn s | |
c1 <- getChar | |
c2 <- getChar | |
cipher_helper $ translate_string [(c1, c2) | |
,(c2, c1) | |
,(toUpper c1, toUpper c2) | |
,(toUpper c2, toUpper c1)] s | |
main = getLine >>= cipher_helper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment