Create a gist now

Instantly share code, notes, and snippets.

@plaster /genmap.hs Secret
Created Feb 12, 2013

What would you like to do?
#!/usr/bin/runghc
type Layout = String
layoutQWERTY :: Layout
layoutQWERTY = "-=" ++
"qwertyuiop[]" ++
"asdfghjkl;'" ++
"zxcvbnm,./" ++
"_+" ++
"QWERTYUIOP{}" ++
"ASDFGHJKL:\"" ++
"ZXCVBNM<>?"
layoutDvorak :: Layout
layoutDvorak = "[]" ++
"',.pyfgcrl/=" ++
"aoeuidhtns-" ++
";qjkxbmwvz" ++
"{}" ++
"\"<>PYFGCRL?+" ++
"AOEUIDHTNS_" ++
":QJKXBMWVZ"
mapCommands :: [String]
mapCommands = ["no", "no!"]
genEntry :: (Char, Char) -> [String]
genEntry (qChar, dChar) = map (\ cmd -> cmd ++ " " ++ [qChar] ++ " " ++ [dChar] ) mapCommands;
genEntries :: Layout -> Layout -> [String]
genEntries srcLayout dstLayout = concatMap genEntry $ zip srcLayout dstLayout
main = do
putStr $ unlines $ genEntries layoutQWERTY layoutDvorak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment