Skip to content

Instantly share code, notes, and snippets.

@monzou
Created June 17, 2012 02:34
Show Gist options
  • Save monzou/2943214 to your computer and use it in GitHub Desktop.
Save monzou/2943214 to your computer and use it in GitHub Desktop.
import Data.Char
main = print $ decode 3 $ encode 3 "hello, world !"
encode :: Int -> String -> String
encode offset msg = map (\c -> chr $ ord c + offset) msg
decode :: Int -> String -> String
decode shift msg = encode (negate shift) msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment